class URIValidatorTest(DBTestCase, RequestMixin): def setUp(self): super(URIValidatorTest, self).setUp() # set's up pylons.translator self.init_fake_request() self.validator = URIValidator() def tearDown(self): self.remove_globals() super(URIValidatorTest, self).tearDown() def to_python(self, value): return self.validator.to_python(value) def test_accepts_http_url(self): url = u'http://site.example/foo/video.ogv' assert_equals(url, self.to_python(url)) def test_accepts_rtmp_url(self): url = u'rtmp://site.example/foo/video.ogv' assert_equals(url, self.to_python(url)) def assert_invalid(self, value): return assert_raises(Invalid, lambda: self.to_python(value)) def test_rejects_invalid_url(self): self.assert_invalid(u'invalid') self.assert_invalid(u'http://?foo=bar') # important to check details of the Python 2.4 urlsplit workaround self.assert_invalid(u'rtmp://') self.assert_invalid(u'rtmp:')
def setUp(self): super(URIValidatorTest, self).setUp() # set's up pylons.translator self.init_fake_request() self.validator = URIValidator()