Beispiel #1
0
    def test_saving_and_retrieving_interest(self):
        first_item = Interest()
        first_item.title = "Test Interest 1"
        first_item.save()

        second_item = Interest()
        second_item.title = "Test Interest 2"
        second_item.save()

        saved_items = Interest.objects.all()
        self.assertEqual(saved_items.count(), 2)

        first_saved_item = saved_items[0]
        second_saved_item = saved_items[1]
        self.assertEqual(first_saved_item.title, 'Test Interest 1')
        self.assertEqual(second_saved_item.title, 'Test Interest 2')
Beispiel #2
0
 def test_delete_interest_unauthenticated(self):
     item = Interest()
     item.title = "Test No Auth Interest 3"
     item.save()
     self.assertEqual(Interest.objects.count(), 1)
     new_item = Interest.objects.first()
     url = "/cv/interest/" + str(new_item.pk) + "/remove/"
     response = self.client.get(url)
     self.assertEqual(Interest.objects.count(), 1)
     self.assertNotEqual(response['location'], "/cv/")
     self.assertEqual(response['location'], "/accounts/login/?next=" + url)
Beispiel #3
0
 def test_edit_buttons_interest_auth(self):
     item = Interest()
     item.title = "Test No Auth Interest EDIT 1"
     item.save()
     self.assertEqual(Interest.objects.count(), 1)
     response = self.client.get('/cv/')
     html = response.content.decode('utf8')
     self.assertNotIn('class="fa icon-switch fa-pencil edit_btn"', html)
     self.assertNotIn('class="fa icon-switch fa-trash delete_btn"', html)
     self.client.login(username='******', password='******')
     response = self.client.get('/cv/')
     html = response.content.decode('utf8')
     self.assertIn('class="fa icon-switch fa-pencil edit_btn"', html)
     self.assertIn('class="fa icon-switch fa-trash delete_btn"', html)
     self.client.logout()
Beispiel #4
0
 def test_edit_interest_post_unauthenticated(self):
     item = Interest()
     item.title = "Test No Auth Interest 2"
     item.save()
     self.assertEqual(Interest.objects.count(), 1)
     new_item = Interest.objects.first()
     url = "/cv/interest/" + str(new_item.pk) + "/edit/"
     data = {
         'title': "Test No Auth Interest 20",
     }
     response = self.client.post(url, data)
     self.assertEqual(Interest.objects.count(), 1)
     self.assertNotEqual(response['location'], "/cv/")
     self.assertEqual(response['location'], "/accounts/login/?next=" + url)
     unedited_item = Interest.objects.first()
     self.assertEqual(unedited_item.title, "Test No Auth Interest 2")