Commit 42a41c707b174a0117171a500680d2799fdde3b4

Authored by Gustavo Bernardo
1 parent e2727664

Starting remove link test [Issue: #125]

Showing 1 changed file with 21 additions and 7 deletions   Show diff stats
links/tests.py
... ... @@ -21,14 +21,28 @@ class LinkTestCase(TestCase):
21 21 self.client.login(username='user', password = 'testing')
22 22 links = Link.objects.all().count()
23 23 self.assertEqual(Link.objects.all().count(),links) #Before creating the link
24   - self.link = Link.objects.create(
25   - name = 'testinglink',
26   - description = 'testdescription',
27   - link = 'teste'
28   - )
  24 + url = reverse('course:create_link')
  25 + data = {
  26 + 'name' : 'testinglink',
  27 + "description" : 'testdescription',
  28 + "link" : 'teste.com'
  29 + }
  30 + response = self.client.post(url, data)
29 31 self.assertEqual(Link.objects.all().count(),links+1) #After creating one link, if OK, the link was created successfully.
  32 + self.assertEqual(response.status_code, 200)
30 33 self.assertTemplateUsed(template_name = 'links/link_modal.html')
31 34 # def test_update_link():
32 35 # pass
33   - # def test_delete_link():
34   - # pass
  36 + def test_delete_link(self):
  37 + self.link = Link.objects.create(
  38 + name = 'testinglink',
  39 + description = 'testdescription',
  40 + link = 'teste.com'
  41 + )
  42 + self.client.login(username='user', password = 'testing')
  43 + links = Link.objects.all().count()
  44 + url = reverse('course:delete_link',kwargs={'linkname': self.link.name})
  45 + self.assertEqual(Link.objects.all().count(),links)
  46 + response = self.client.get(url)
  47 + self.assertEqual(Link.objects.all().count(),links - 1)
  48 + self.assertEqual(response.status_code, 200)
... ...