From 7cb40c8a261a916d81e0cebad56ef96e5966b2fd Mon Sep 17 00:00:00 2001 From: Jeremiah Date: Sat, 11 Jul 2020 16:44:48 -0500 Subject: [PATCH 1/3] updated website view tests --- website/tests.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/website/tests.py b/website/tests.py index 5bb34bf..79f1e8a 100644 --- a/website/tests.py +++ b/website/tests.py @@ -12,10 +12,10 @@ def test_form_data_view_passed(self): "case_num": "CF-2020-1648", "year": 2020, "county": "Tulsa", - "phone_num": 918-555-5555, - "add_phone_num": 918-111-1111 + "phone_num": "000-000-0000", + "add_phone_num": "000-000-0001" } - resp = self.client.post("https://courtbot-python.herokuapp.com/form_data", data=data, follow=True) + resp = self.client.post("https://courtbot-python.herokuapp.com/schedule_reminders", data=data, follow=True) self.assertIn(str.encode("Arraignment for case CF-2020-1648 has already passed"), resp.content) @@ -24,10 +24,10 @@ def test_form_data_view_not_found(self): "case_num": "1000000000", "year": 2020, "county": "Tulsa", - "phone_num": 918-555-5555, - "add_phone_num": 918-111-1111 + "phone_num": "000-000-0000", + "add_phone_num": "000-000-0001" } - resp = self.client.post("https://courtbot-python.herokuapp.com/form_data", data=data, follow=True) + resp = self.client.post("https://courtbot-python.herokuapp.com/schedule_reminders", data=data, follow=True) self.assertIn(str.encode("Unable to find arraignment event with the following year 2020, county Tulsa, case number 1000000000"), resp.content) @@ -36,10 +36,10 @@ def test_form_data_view_scheduled(self): "case_num": "CF-2020-2803", "year": 2020, "county": "Tulsa", - "phone_num": 918-555-5555, - "add_phone_num": 918-111-1111 + "phone_num": "000-000-0000", + "add_phone_num": "000-000-0001" } - resp = self.client.post("https://courtbot-python.herokuapp.com/form_data", data=data, follow=True) + resp = self.client.post("https://courtbot-python.herokuapp.com/schedule_reminders", data=data, follow=True) - self.assertIn(str.encode("Reminder scheduled"), resp.content) + self.assertIn(str.encode("Text reminder for case CF-2020-2803 occuring on 2020-07-21T09:00:00 was scheduled under 000-000-0000."), resp.content) From 4069944b618eab5afd763995ad5240fb560a017a Mon Sep 17 00:00:00 2001 From: Jeremiah Date: Tue, 4 Aug 2020 22:00:29 -0500 Subject: [PATCH 2/3] updated success case number --- website/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/tests.py b/website/tests.py index 79f1e8a..8e26449 100644 --- a/website/tests.py +++ b/website/tests.py @@ -33,7 +33,7 @@ def test_form_data_view_not_found(self): def test_form_data_view_scheduled(self): data = { - "case_num": "CF-2020-2803", + "case_num": "CF-2020-3314", "year": 2020, "county": "Tulsa", "phone_num": "000-000-0000", @@ -41,5 +41,5 @@ def test_form_data_view_scheduled(self): } resp = self.client.post("https://courtbot-python.herokuapp.com/schedule_reminders", data=data, follow=True) - self.assertIn(str.encode("Text reminder for case CF-2020-2803 occuring on 2020-07-21T09:00:00 was scheduled under 000-000-0000."), resp.content) + self.assertIn(str.encode("Text reminder for case CF-2020-3314 occuring on 2020-08-13T09:00:00 was scheduled under 000-000-0000."), resp.content) From 2d3256bab910488714412a0b0be42e075775c144 Mon Sep 17 00:00:00 2001 From: Jeremiah Date: Wed, 5 Aug 2020 19:43:29 -0500 Subject: [PATCH 3/3] added mock success case test --- website/tests.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/website/tests.py b/website/tests.py index 8e26449..66bb245 100644 --- a/website/tests.py +++ b/website/tests.py @@ -1,4 +1,6 @@ from django.test import TestCase, RequestFactory, Client +import unittest +from unittest.mock import patch import json class testFormViews(TestCase): @@ -31,9 +33,12 @@ def test_form_data_view_not_found(self): self.assertIn(str.encode("Unable to find arraignment event with the following year 2020, county Tulsa, case number 1000000000"), resp.content) - def test_form_data_view_scheduled(self): + @patch('website.views.check_valid_case') + def test_form_data_view_scheduled(self, mock_arraignment): + + mock_arraignment.return_value = '','2020-08-13T09:00:00' data = { - "case_num": "CF-2020-3314", + "case_num": "CF-0000-0001", "year": 2020, "county": "Tulsa", "phone_num": "000-000-0000", @@ -41,5 +46,4 @@ def test_form_data_view_scheduled(self): } resp = self.client.post("https://courtbot-python.herokuapp.com/schedule_reminders", data=data, follow=True) - self.assertIn(str.encode("Text reminder for case CF-2020-3314 occuring on 2020-08-13T09:00:00 was scheduled under 000-000-0000."), resp.content) - + self.assertIn(str.encode("Text reminder for case CF-0000-0001 occuring on 2020-08-13T09:00:00 was scheduled under 000-000-0000."), resp.content) \ No newline at end of file