From 42a41c707b174a0117171a500680d2799fdde3b4 Mon Sep 17 00:00:00 2001 From: Gustavo Bernardo Date: Wed, 12 Oct 2016 23:15:52 -0300 Subject: [PATCH] Starting remove link test [Issue: #125] --- links/tests.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/links/tests.py b/links/tests.py index 493214e..e017ee3 100644 --- a/links/tests.py +++ b/links/tests.py @@ -21,14 +21,28 @@ class LinkTestCase(TestCase): self.client.login(username='user', password = 'testing') links = Link.objects.all().count() self.assertEqual(Link.objects.all().count(),links) #Before creating the link - self.link = Link.objects.create( - name = 'testinglink', - description = 'testdescription', - link = 'teste' - ) + url = reverse('course:create_link') + data = { + 'name' : 'testinglink', + "description" : 'testdescription', + "link" : 'teste.com' + } + response = self.client.post(url, data) self.assertEqual(Link.objects.all().count(),links+1) #After creating one link, if OK, the link was created successfully. + self.assertEqual(response.status_code, 200) self.assertTemplateUsed(template_name = 'links/link_modal.html') # def test_update_link(): # pass - # def test_delete_link(): - # pass + def test_delete_link(self): + self.link = Link.objects.create( + name = 'testinglink', + description = 'testdescription', + link = 'teste.com' + ) + self.client.login(username='user', password = 'testing') + links = Link.objects.all().count() + url = reverse('course:delete_link',kwargs={'linkname': self.link.name}) + self.assertEqual(Link.objects.all().count(),links) + response = self.client.get(url) + self.assertEqual(Link.objects.all().count(),links - 1) + self.assertEqual(response.status_code, 200) -- libgit2 0.21.2