Commit e6b1fd3f4d61b8d52f8da0cb7e7c34cde33a9f9e
1 parent
ba384ee6
Exists in
master
and in
5 other branches
Finished the create link test [Issue: #123]
Showing
1 changed file
with
13 additions
and
5 deletions
Show diff stats
links/tests.py
@@ -29,12 +29,20 @@ class LinkTestCase(TestCase): | @@ -29,12 +29,20 @@ class LinkTestCase(TestCase): | ||
29 | "description" : 'testdescription', | 29 | "description" : 'testdescription', |
30 | "link" : 'teste.com' | 30 | "link" : 'teste.com' |
31 | } | 31 | } |
32 | - response = self.client.post(url, data) | ||
33 | - #self.assertEqual(response.status_code, 200) | ||
34 | - self.assertFormError(response,'form',"link",_("Please enter a valid URL")) | ||
35 | - self.assertEqual(Link.objects.all().count(),links+1) #After creating one link, if OK, the link was created successfully. | 32 | + response = self.client.post(url, data,format = 'json') |
33 | + link1 = Link.objects.get(name = data['name']) #Link criado com os dados inseridos corretamente | ||
34 | + self.assertEqual(Link.objects.filter(name= link1.name).exists(),True) #Verificada existência do link | ||
35 | + self.assertEqual(Link.objects.all().count(),links+1) #After creating link1, if OK, the link was created successfully. | ||
36 | self.assertEqual(response.status_code, 302) #If OK, User is getting redirected correctly. | 36 | self.assertEqual(response.status_code, 302) #If OK, User is getting redirected correctly. |
37 | - self.assertTemplateUsed(template_name = 'links/link_modal.html') | 37 | + self.assertTemplateUsed(template_name = 'links/create_link.html') |
38 | + data = { | ||
39 | + 'name' : 'testlink2', | ||
40 | + "description" : 'testdescription2', | ||
41 | + "link" : 'teste' | ||
42 | + } | ||
43 | + response = self.client.post(url, data,format = 'json') | ||
44 | + self.assertEqual(Link.objects.filter(name= data['name']).exists(),False) #Verificada não existência do link com campo errado | ||
45 | + | ||
38 | # def test_update_link(): | 46 | # def test_update_link(): |
39 | # pass | 47 | # pass |
40 | def test_delete_link(self): | 48 | def test_delete_link(self): |