示例#1
0
 def test_tag(self):
     """
     Testing custom tag
     """
     profile = Profile.objects.first()
     template = Template("{% load hello_tags %}"
                         "{% edit_link profile %}")
     rendered = template.render(Context({'profile': profile}))
     self.assertIn(edit_link(profile),
                   rendered)
示例#2
0
 def test_tag_add_another_object(self):
     """
     Give request object to tag
     """
     Requests(request='request',
              pub_date=t.now() + t.timedelta(hours=3),
              path='/'
              ).save()
     req = Requests.objects.first()
     template = Template("{% load hello_tags %}"
                         "{% edit_link request %}")
     rendered = template.render(Context({'request': req}))
     self.assertIn(edit_link(req),
                   rendered)
示例#3
0
 def test_tag_with_not_edit_model(self):
     """
     Testing custom tag
     """
     content_type = ContentType.objects.first()
     self.assertRaises(NoReverseMatch, lambda: edit_link(content_type))
示例#4
0
 def test_tag_with_wrong_data(self):
     """
     Testing custom tag
     """
     self.assertRaises(ObjectDoesNotExist, lambda: edit_link(123))
示例#5
0
 def test_tag_with_not_edit_model(self):
     """
     Testing custom tag
     """
     content_type = ContentType.objects.first()
     self.assertRaises(NoReverseMatch, lambda: edit_link(content_type))
示例#6
0
 def test_tag_with_wrong_data(self):
     """
     Testing custom tag
     """
     self.assertRaises(ObjectDoesNotExist, lambda: edit_link(123))