コード例 #1
0
 def test_add_new_request_and_delete(self):
     """
     Check can add and delete date from DB.
     """
     request = Requests(request="new_1", path="new")
     request.save()
     request = Requests.objects.get(id=2)
     self.assertEqual(request.request, "new_1")
     self.assertEqual(request.path, "new")
     Requests.objects.get(id=2).delete()
     self.assertEqual(Requests.objects.count(), 1)
コード例 #2
0
 def test_is_data_in_template_and_database_same(self):
     """
     Check that data in template and DB same.
     """
     if not Requests.objects.count():
         request = Requests(request="new_test", path="new_test")
         request.save()
     request = Requests.objects.last()
     client = Client()
     response = client.get("/requests/")
     self.assertContains(response, request.request)
     request.request = "test_is_data_in_template_and_database_same"
     request.save()
     client = Client()
     response = client.get("/requests/")
     self.assertContains(response, request.request)