Пример #1
0
 def setUp(self):
     url = ShortUrl()
     url.default_url = 'http://bbc.com'
     url.mobile_url = 'http://m.bbc.com'
     url.tablet_url = 'http://t.bbc.com'
     url.save()
     url = ShortUrl()
     url.default_url = 'http://google.com'
     url.save()
Пример #2
0
 def test_str_representation(self):
     ShortUrl.objects.all().delete()
     url = ShortUrl()
     url.default_url = 'http://google.com'
     url.save()
     u = ShortUrl.objects.get(default_url='http://google.com')
     self.assertEqual(str(u), 'Short Url:3e9 Default Url:http://google.com')
Пример #3
0
 def test_invalid_url_returns_error(self):
     with self.assertRaises(Exception) as context:
         ShortUrl.objects.all().delete()
         u = ShortUrl()
         u.default_url = 'http://googl'
         u.save()
         self.assertTrue('This is broken' in context.exception)
     self.assertEqual(ShortUrl.objects.all().count(), 0)