From d82b2b9b7752603cc34ae9aa3e9b5aedbfad844f Mon Sep 17 00:00:00 2001 From: jdungan Date: Wed, 6 Nov 2019 09:37:09 -0600 Subject: [PATCH 1/3] update to oscn v59, refactor arraignment with new event dict --- api/tests.py | 36 +++++++++++++++++++++++++++++++++++- api/views.py | 13 ++++++++----- requirements.txt | 2 +- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/api/tests.py b/api/tests.py index 7ce503c..3b3d6e5 100644 --- a/api/tests.py +++ b/api/tests.py @@ -1,3 +1,37 @@ from django.test import TestCase +from django.test.client import RequestFactory +from django.urls import reverse -# Create your tests here. +from api.views import reminders, case + + +class caseViewTest(TestCase): + def setUp(self): + self.url = reverse('case') + self.factory = RequestFactory() + + def test_case(self): + params = { + "year": "2014", + "county":"tulsa", + "case_num": "5203" + } + request = self.factory.get(self.url, params) + response = case(request) + self.assertEqual(response.status_code, 200) + + +class remindersViewTest(TestCase): + def setUp(self): + self.url = reverse('reminders') + self.factory = RequestFactory() + + def test_reminders(self): + params = { + "case_num": "CF-2014-5203", + "phone_num":"19182615259", + "arraignment_datetime": "2019-09-17T08:00:00" + } + request = self.factory.post(self.url, params) + response = reminders(request) + self.assertEqual(response.status_code, 201) diff --git a/api/views.py b/api/views.py index ab01544..90ed7f4 100644 --- a/api/views.py +++ b/api/views.py @@ -34,7 +34,7 @@ def case(request): f'year {year}, county {county}, case number {case_num}') return JsonResponse({'error': err_msg}) arraignment_datetime = parse_datetime_from_oscn_event_string( - arraignment_event.Event + arraignment_event ) return JsonResponse({ @@ -78,11 +78,14 @@ def reminders(request): def find_arraignment_or_return_False(events): for event in events: - if "arraignment" in event.Docket.lower(): - return event + if "description" in event.keys(): + if event['description'] == 'ARRAIGNMENT': + return event return False def parse_datetime_from_oscn_event_string(event): - event = event.replace('ARRAIGNMENT', '').rstrip() - return datetime.strptime(event, "%A, %B %d, %Y at %I:%M %p") + if 'date' in event.keys(): + date_str = event['date'] + return datetime.strptime(date_str, "%A, %B %d, %Y at %I:%M %p") + return False diff --git a/requirements.txt b/requirements.txt index 5f57260..364f3df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ Django==2.1.11 gunicorn==19.9.0 -oscn==0.0.0.32 +oscn==0.0.0.59 python-decouple==3.1 twilio==6.24.0 django-heroku==0.3.1 From 0f7c4b15e14fd582ab97f08dc9cd72477edc0a83 Mon Sep 17 00:00:00 2001 From: jdungan Date: Wed, 6 Nov 2019 13:10:32 -0600 Subject: [PATCH 2/3] move tests to dir --- api/tests.py | 36 +----------------------------------- api/tests/test_views.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 api/tests/test_views.py diff --git a/api/tests.py b/api/tests.py index 3b3d6e5..7ce503c 100644 --- a/api/tests.py +++ b/api/tests.py @@ -1,37 +1,3 @@ from django.test import TestCase -from django.test.client import RequestFactory -from django.urls import reverse -from api.views import reminders, case - - -class caseViewTest(TestCase): - def setUp(self): - self.url = reverse('case') - self.factory = RequestFactory() - - def test_case(self): - params = { - "year": "2014", - "county":"tulsa", - "case_num": "5203" - } - request = self.factory.get(self.url, params) - response = case(request) - self.assertEqual(response.status_code, 200) - - -class remindersViewTest(TestCase): - def setUp(self): - self.url = reverse('reminders') - self.factory = RequestFactory() - - def test_reminders(self): - params = { - "case_num": "CF-2014-5203", - "phone_num":"19182615259", - "arraignment_datetime": "2019-09-17T08:00:00" - } - request = self.factory.post(self.url, params) - response = reminders(request) - self.assertEqual(response.status_code, 201) +# Create your tests here. diff --git a/api/tests/test_views.py b/api/tests/test_views.py new file mode 100644 index 0000000..3b3d6e5 --- /dev/null +++ b/api/tests/test_views.py @@ -0,0 +1,37 @@ +from django.test import TestCase +from django.test.client import RequestFactory +from django.urls import reverse + +from api.views import reminders, case + + +class caseViewTest(TestCase): + def setUp(self): + self.url = reverse('case') + self.factory = RequestFactory() + + def test_case(self): + params = { + "year": "2014", + "county":"tulsa", + "case_num": "5203" + } + request = self.factory.get(self.url, params) + response = case(request) + self.assertEqual(response.status_code, 200) + + +class remindersViewTest(TestCase): + def setUp(self): + self.url = reverse('reminders') + self.factory = RequestFactory() + + def test_reminders(self): + params = { + "case_num": "CF-2014-5203", + "phone_num":"19182615259", + "arraignment_datetime": "2019-09-17T08:00:00" + } + request = self.factory.post(self.url, params) + response = reminders(request) + self.assertEqual(response.status_code, 201) From 9009fe7ce657ae098ae3646f78c776bdece244a1 Mon Sep 17 00:00:00 2001 From: jdungan Date: Sun, 10 Nov 2019 09:18:16 -0600 Subject: [PATCH 3/3] use version 60 with new case search --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 364f3df..5b91cfe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ Django==2.1.11 gunicorn==19.9.0 -oscn==0.0.0.59 +oscn==0.0.0.60 python-decouple==3.1 twilio==6.24.0 django-heroku==0.3.1