Skip to content

Commit

Permalink
Added test for parsed_url
Browse files Browse the repository at this point in the history
  • Loading branch information
seocam committed Jun 5, 2015
1 parent 41fce2a commit 7e4b72a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os

from django.test import TestCase, RequestFactory
from django.utils.six.moves.urllib.parse import ParseResult

from revproxy.exceptions import InvalidUpstream
from revproxy.views import ProxyView, DiazoProxyView
Expand All @@ -25,6 +26,21 @@ def test_upstream_not_implemented(self):
with self.assertRaises(NotImplementedError):
upstream = proxy_view.upstream

def test_upstream_parsed_url_cache(self):
class CustomProxyView(ProxyView):
upstream = 'http://www.example.com'

proxy_view = CustomProxyView()
with self.assertRaises(AttributeError):
proxy_view._parsed_url

# Test for parsed URL
proxy_view.get_upstream()
self.assertIsInstance(proxy_view._parsed_url, ParseResult)
# Get parsed URL from cache
proxy_view.get_upstream()
self.assertIsInstance(proxy_view._parsed_url, ParseResult)

def test_upstream_without_scheme(self):
class BrokenProxyView(ProxyView):
upstream = 'www.example.com'
Expand Down

0 comments on commit 7e4b72a

Please sign in to comment.