diff --git a/website/tests.py b/website/tests.py index 5bb34bf..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): @@ -12,10 +14,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,22 +26,24 @@ 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) - 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-2803", + "case_num": "CF-0000-0001", "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) - - self.assertIn(str.encode("Reminder scheduled"), resp.content) + resp = self.client.post("https://courtbot-python.herokuapp.com/schedule_reminders", data=data, follow=True) + 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