From e6b1fd3f4d61b8d52f8da0cb7e7c34cde33a9f9e Mon Sep 17 00:00:00 2001 From: Gustavo Bernardo Date: Thu, 13 Oct 2016 23:21:11 -0300 Subject: [PATCH] Finished the create link test [Issue: #123] --- links/tests.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/links/tests.py b/links/tests.py index 679f0b4..7e88b70 100644 --- a/links/tests.py +++ b/links/tests.py @@ -29,12 +29,20 @@ class LinkTestCase(TestCase): "description" : 'testdescription', "link" : 'teste.com' } - response = self.client.post(url, data) - #self.assertEqual(response.status_code, 200) - self.assertFormError(response,'form',"link",_("Please enter a valid URL")) - self.assertEqual(Link.objects.all().count(),links+1) #After creating one link, if OK, the link was created successfully. + response = self.client.post(url, data,format = 'json') + link1 = Link.objects.get(name = data['name']) #Link criado com os dados inseridos corretamente + self.assertEqual(Link.objects.filter(name= link1.name).exists(),True) #Verificada existência do link + self.assertEqual(Link.objects.all().count(),links+1) #After creating link1, if OK, the link was created successfully. self.assertEqual(response.status_code, 302) #If OK, User is getting redirected correctly. - self.assertTemplateUsed(template_name = 'links/link_modal.html') + self.assertTemplateUsed(template_name = 'links/create_link.html') + data = { + 'name' : 'testlink2', + "description" : 'testdescription2', + "link" : 'teste' + } + response = self.client.post(url, data,format = 'json') + self.assertEqual(Link.objects.filter(name= data['name']).exists(),False) #Verificada não existência do link com campo errado + # def test_update_link(): # pass def test_delete_link(self): -- libgit2 0.21.2