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)
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)
def test_tag_with_not_edit_model(self): """ Testing custom tag """ content_type = ContentType.objects.first() self.assertRaises(NoReverseMatch, lambda: edit_link(content_type))
def test_tag_with_wrong_data(self): """ Testing custom tag """ self.assertRaises(ObjectDoesNotExist, lambda: edit_link(123))