示例#1
0
 def test_get_full_url_without_schema(self):
     settings.SITE_PROTOCOL = 'https'
     m = Meta()
     self.assertEqual(
         m.get_full_url('//foo.com/foo/bar'),
         'https://foo.com/foo/bar'
     )
示例#2
0
 def test_get_full_url_without_schema(self):
     meta.settings.SITE_PROTOCOL = 'https'
     m = Meta()
     self.assertEqual(
         m.get_full_url('//foo.com/foo/bar'),
         'https://foo.com/foo/bar'
     )
示例#3
0
 def test_get_full_url_with_absolute_path(self):
     meta.settings.SITE_PROTOCOL = 'https'
     meta.settings.SITE_DOMAIN = 'foo.com'
     m = Meta()
     self.assertEqual(
         m.get_full_url('/foo/bar'),
         'https://foo.com/foo/bar'
     )
示例#4
0
 def test_get_full_url_with_domain_and_protocol(self):
     meta.settings.SITE_PROTOCOL = 'https'
     meta.settings.SITE_DOMAIN = 'foo.com'
     m = Meta()
     self.assertEqual(
         m.get_full_url('foo/bar'),
         'https://foo.com/foo/bar'
     )
示例#5
0
 def test_get_full_url_without_site_id_with_request_will_not_raise(self):
     settings.USE_SITES = True
     settings.SITE_PROTOCOL = 'http'
     factory = RequestFactory()
     request = factory.get('/')
     Site.objects.create(domain=request.get_host())
     m = Meta(request=request)
     self.assertEqual(m.get_full_url('foo/bar'),
                      'http://testserver/foo/bar')
示例#6
0
 def test_get_full_url_without_site_id_with_request_will_not_raise(self):
     settings.USE_SITES = True
     settings.SITE_PROTOCOL = 'http'
     factory = RequestFactory()
     request = factory.get('/')
     Site.objects.create(domain=request.get_host())
     m = Meta(request=request)
     self.assertEqual(
         m.get_full_url('foo/bar'),
         'http://testserver/foo/bar'
     )
示例#7
0
 def test_get_full_url_without_domain_will_raise(self):
     meta.settings.SITE_PROTOCOL = 'http'
     m = Meta()
     with self.assertRaises(ImproperlyConfigured):
         m.get_full_url('foo/bar')
示例#8
0
 def test_get_full_url_without_protocol_will_raise(self):
     m = Meta()
     with self.assertRaises(ImproperlyConfigured):
         m.get_full_url('foo/bar')
示例#9
0
 def test_get_full_url_with_full_url(self):
     m = Meta()
     self.assertEqual(
         m.get_full_url('http://example.com/foo'),
         'http://example.com/foo'
     )
示例#10
0
 def test_get_full_url_with_None(self):
     m = Meta()
     self.assertEqual(m.get_full_url(None), None)
示例#11
0
 def test_get_full_url_without_site_id_will_raise(self):
     settings.USE_SITES = True
     settings.SITE_PROTOCOL = 'http'
     m = Meta()
     with self.assertRaises(ImproperlyConfigured):
         m.get_full_url('foo/bar')
示例#12
0
 def test_get_full_url_with_absolute_path(self):
     meta.settings.SITE_PROTOCOL = "https"
     meta.settings.SITE_DOMAIN = "foo.com"
     m = Meta()
     self.assertEqual(m.get_full_url("/foo/bar"), "https://foo.com/foo/bar")
示例#13
0
 def test_get_full_url_with_domain_and_protocol(self):
     meta.settings.SITE_PROTOCOL = "https"
     meta.settings.SITE_DOMAIN = "foo.com"
     m = Meta()
     self.assertEqual(m.get_full_url("foo/bar"), "https://foo.com/foo/bar")
示例#14
0
 def test_get_full_url_without_site_id_will_raise(self):
     settings.USE_SITES = True
     settings.SITE_PROTOCOL = 'http'
     m = Meta()
     with self.assertRaises(ImproperlyConfigured):
         m.get_full_url('foo/bar')