Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions website/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.test import TestCase, RequestFactory, Client
import unittest
from unittest.mock import patch
import json

class testFormViews(TestCase):
Expand All @@ -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)

Expand All @@ -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)