From a781cb1948b7cb2cd0483f77195a7cadb5147009 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Sun, 24 Mar 2019 11:27:51 -0500 Subject: [PATCH 01/12] Revert "Revert "Move to python 3"" (i.e. go back to py3.) This reverts commit 14b571dee89b7fd44d0b3dca50a05f07077b269d. --- .circleci/config.yml | 2 +- api/test.py | 87 ++++++++++--------- appointment/models.py | 2 +- .../appointment/appointment_list.html | 2 +- appointment/test_views.py | 12 +-- audit/models.py | 2 +- .../0001_squashed_0003_auto_20170623_1048.py | 8 +- demographics/models.py | 12 +-- demographics/urls.py | 2 +- followup/admin.py | 2 +- followup/models.py | 8 +- followup/tests.py | 2 +- followup/urls.py | 2 +- .../0001_squashed_0010_auto_20170623_1300.py | 19 ++-- pttrack/models.py | 62 +++++++------ pttrack/test_forms.py | 2 +- pttrack/test_utils.py | 2 +- pttrack/test_validators.py | 2 +- pttrack/test_views.py | 21 +++-- referral/forms.py | 2 +- referral/models.py | 4 +- referral/tests.py | 20 ++--- referral/urls.py | 2 +- workup/admin.py | 2 +- workup/migrations/0001_initial.py | 18 ++-- workup/models.py | 8 +- workup/test_models.py | 2 +- workup/urls.py | 2 +- 28 files changed, 163 insertions(+), 148 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8711a35..6c4da6c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: docker: - - image: circleci/python:2.7.15-jessie-browsers + - image: circleci/python:3.6.8-jessie-browsers steps: - checkout - run: mkdir test-reports diff --git a/api/test.py b/api/test.py index eea9b7f..f587e4a 100644 --- a/api/test.py +++ b/api/test.py @@ -18,16 +18,16 @@ class APITest(APITestCase): def setUp(self): workupModels.ClinicType.objects.create(name="Basic Care Clinic") workupModels.ClinicDate.objects.create( - clinic_type=workupModels.ClinicType.objects.all()[0], - clinic_date=now().date()+datetime.timedelta(days=1), + clinic_type=workupModels.ClinicType.objects.first(), + clinic_date=now().date() + datetime.timedelta(days=1), gcal_id="tmp") workupModels.ClinicDate.objects.create( - clinic_type=workupModels.ClinicType.objects.all()[0], - clinic_date=now().date()-datetime.timedelta(days=1), + clinic_type=workupModels.ClinicType.objects.first(), + clinic_date=now().date() - datetime.timedelta(days=1), gcal_id="tmp") workupModels.ClinicDate.objects.create( - clinic_type=workupModels.ClinicType.objects.all()[0], - clinic_date=now().date()-datetime.timedelta(days=5), + clinic_type=workupModels.ClinicType.objects.first(), + clinic_date=now().date() - datetime.timedelta(days=5), gcal_id="tmp") log_in_provider(self.client, build_provider(["Attending"])) @@ -44,9 +44,9 @@ def setUp(self): state='BA', zip_code='63108', pcp_preferred_zip='63018', - date_of_birth=datetime.date(1990, 01, 01), + date_of_birth=datetime.date(1990, 1, 1), patient_comfortable_with_english=False, - preferred_contact_method=models.ContactMethod.objects.all()[0], + preferred_contact_method=models.ContactMethod.objects.first(), ) pt3 = models.Patient.objects.create( @@ -54,15 +54,15 @@ def setUp(self): last_name="Lkjh", middle_name="Bayer", phone='+49 178 236 5288', - gender=models.Gender.objects.all()[0], + gender=models.Gender.objects.first(), address='Schulstrasse 9', city='Munich', state='BA', zip_code='63108', pcp_preferred_zip='63018', - date_of_birth=datetime.date(1990, 01, 01), + date_of_birth=datetime.date(1990, 1, 1), patient_comfortable_with_english=False, - preferred_contact_method=models.ContactMethod.objects.all()[0], + preferred_contact_method=models.ContactMethod.objects.first(), ) pt4 = models.Patient.objects.create( @@ -70,26 +70,26 @@ def setUp(self): last_name="Action", middle_name="Item", phone='+12 345 678 9000', - gender=models.Gender.objects.all()[0], + gender=models.Gender.objects.first(), address='Schulstrasse 9', city='Munich', state='BA', zip_code='63108', pcp_preferred_zip='63018', - date_of_birth=datetime.date(1990, 01, 01), + date_of_birth=datetime.date(1990, 1, 1), patient_comfortable_with_english=False, - preferred_contact_method=models.ContactMethod.objects.all()[0], + preferred_contact_method=models.ContactMethod.objects.first(), ) # Give pt2 a workup one day later. workupModels.Workup.objects.create( - clinic_day=workupModels.ClinicDate.objects.all()[0], # one day later + clinic_day=workupModels.ClinicDate.objects.first(), # one day later chief_complaint="SOB", diagnosis="MI", HPI="", PMH_PSH="", meds="", allergies="", fam_hx="", soc_hx="", ros="", pe="", A_and_P="", - author=models.Provider.objects.all()[0], - author_type=models.ProviderType.objects.all()[0], + author=models.Provider.objects.first(), + author_type=models.ProviderType.objects.first(), patient=pt2) # Give pt3 a workup one day ago. @@ -99,8 +99,8 @@ def setUp(self): diagnosis="MI", HPI="", PMH_PSH="", meds="", allergies="", fam_hx="", soc_hx="", ros="", pe="", A_and_P="", - author=models.Provider.objects.all()[0], - author_type=models.ProviderType.objects.all()[0], + author=models.Provider.objects.first(), + author_type=models.ProviderType.objects.first(), patient=pt3) @@ -111,8 +111,8 @@ def setUp(self): diagnosis="MI", HPI="", PMH_PSH="", meds="", allergies="", fam_hx="", soc_hx="", ros="", pe="", A_and_P="", - author=models.Provider.objects.all()[0], - author_type=models.ProviderType.objects.all()[0], + author=models.Provider.objects.first(), + author_type=models.ProviderType.objects.first(), patient=pt1, signer=models.Provider.objects.all().filter( clinical_roles=models.ProviderType.objects.all().filter( @@ -120,9 +120,9 @@ def setUp(self): # make pt1 have and AI due tomorrow pt1_ai = models.ActionItem.objects.create( - author=models.Provider.objects.all()[0], - author_type=models.ProviderType.objects.all()[0], - instruction=models.ActionInstruction.objects.all()[0], + author=models.Provider.objects.first(), + author_type=models.ProviderType.objects.first(), + instruction=models.ActionInstruction.objects.first(), due_date=now().date()+datetime.timedelta(days=1), comments="", priority=True, @@ -130,9 +130,9 @@ def setUp(self): # make pt2 have an AI due yesterday pt2_ai = models.ActionItem.objects.create( - author=models.Provider.objects.all()[0], - author_type=models.ProviderType.objects.all()[0], - instruction=models.ActionInstruction.objects.all()[0], + author=models.Provider.objects.first(), + author_type=models.ProviderType.objects.first(), + instruction=models.ActionInstruction.objects.first(), due_date=now().date()-datetime.timedelta(days=1), comments="", priority=True, @@ -140,9 +140,9 @@ def setUp(self): # make pt3 have an AI that during the test will be marked done pt3_ai = models.ActionItem.objects.create( - author=models.Provider.objects.all()[0], - author_type=models.ProviderType.objects.all()[0], - instruction=models.ActionInstruction.objects.all()[0], + author=models.Provider.objects.first(), + author_type=models.ProviderType.objects.first(), + instruction=models.ActionInstruction.objects.first(), due_date=now().date()-datetime.timedelta(days=15), comments="", patient=pt3) @@ -152,16 +152,19 @@ def test_api_list_patients_by_last_name(self): url = reverse("pt_list_api") # Way to have this here and not repeat this line? Reverse is called in every test now # Test last_name ordering - data = {'sort':'last_name'} + data = {'sort': 'last_name'} response = self.client.get(reverse("pt_list_api"), data, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertLessEqual(response.data[0]['last_name'],response.data[1]['last_name']) - self.assertLessEqual(response.data[1]['last_name'],response.data[2]['last_name']) - self.assertLessEqual(response.data[2]['last_name'],response.data[3]['last_name']) + self.assertLessEqual(response.data[0]['last_name'], + response.data[1]['last_name']) + self.assertLessEqual(response.data[1]['last_name'], + response.data[2]['last_name']) + self.assertLessEqual(response.data[2]['last_name'], + response.data[3]['last_name']) def test_api_list_patients_by_latest_activity(self): # Test workup/intake ordering. - data = {'sort':'latest_workup'} + data = {'sort': 'latest_workup'} response = self.client.get(reverse("pt_list_api"), data, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertNotEqual(response.data[0]['latest_workup'], None) # pt2, workup date now()+1day @@ -170,9 +173,15 @@ def test_api_list_patients_by_latest_activity(self): self.assertNotEqual(response.data[3]['latest_workup'], None) # pt1, workup date now()-5days # Check that dates are correcly sorted - self.assertGreaterEqual(response.data[0]['latest_workup']['clinic_day']['clinic_date'],response.data[1]['history']['last']['history_date']) - self.assertGreaterEqual(response.data[1]['history']['last']['history_date'],response.data[2]['latest_workup']['clinic_day']['clinic_date']) - self.assertGreaterEqual(response.data[2]['latest_workup']['clinic_day']['clinic_date'],response.data[3]['latest_workup']['clinic_day']['clinic_date']) + self.assertGreaterEqual( + response.data[0]['latest_workup']['clinic_day']['clinic_date'], + response.data[1]['history']['last']['history_date']) + self.assertGreaterEqual( + response.data[1]['history']['last']['history_date'], + response.data[2]['latest_workup']['clinic_day']['clinic_date']) + self.assertGreaterEqual( + response.data[2]['latest_workup']['clinic_day']['clinic_date'], + response.data[3]['latest_workup']['clinic_day']['clinic_date']) def test_api_list_patients_with_unsigned_workup(self): # Test for unsigned_workup @@ -228,7 +237,7 @@ def test_api_list_patients_with_inactive_action_item(self): self.assertEqual(len(response.data), 1) self.assertEqual(response.data[0]['id'], pt1.id) - pt3_ai.mark_done(models.Provider.objects.all()[0]) + pt3_ai.mark_done(models.Provider.objects.first()) pt3_ai.save() # Test now only has pt2 diff --git a/appointment/models.py b/appointment/models.py index 97306e4..c1b63d6 100644 --- a/appointment/models.py +++ b/appointment/models.py @@ -44,7 +44,7 @@ class Appointment(Note): history = HistoricalRecords() - def __unicode__(self): + def __str__(self): return "Appointment ({type}) for {name} on {date}".format( type=self.verbose_appointment_type(), name=self.patient.name(), diff --git a/appointment/templates/appointment/appointment_list.html b/appointment/templates/appointment/appointment_list.html index f81c749..a6da3b9 100644 --- a/appointment/templates/appointment/appointment_list.html +++ b/appointment/templates/appointment/appointment_list.html @@ -15,7 +15,7 @@

Appointment List

{% block content %}
- {% for date, app_list in appointments_by_date.iteritems %} + {% for date, app_list in appointments_by_date.items %}
Date: Tue, 22 Oct 2019 20:50:08 -0500 Subject: [PATCH 02/12] Remove merge confict indicators. --- pttrack/models.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pttrack/models.py b/pttrack/models.py index 7aac975..9107f39 100644 --- a/pttrack/models.py +++ b/pttrack/models.py @@ -517,9 +517,6 @@ def attribution(self): return " ".join(["Added by", str(self.author), "on", str(self.written_datetime.date())]) -<<<<<<< HEAD - def __str__(self): -======= def mark_done_url(self): return reverse(self.MARK_DONE_URL_NAME, args=(self.id,)) @@ -527,7 +524,6 @@ def admin_url(self): return reverse('admin:pttrack_actionitem_change', args=(self.id,)) - def __unicode__(self): ->>>>>>> master - return " ".join(["AI for", str(self.patient)+":", + def __str__(self): + return " ".join(["AI for", str(self.patient) + ":", str(self.instruction), "due on", str(self.due_date)]) From dd8cad9b77d8712f148aadd2d3f95c030088cce7 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Tue, 22 Oct 2019 21:06:38 -0500 Subject: [PATCH 03/12] fix python 3 stuff --- dashboard/tests.py | 4 ++-- pttrack/test_views.py | 3 --- workup/admin.py | 3 --- workup/tests.py | 3 --- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/dashboard/tests.py b/dashboard/tests.py index e74c5a3..066e1ff 100644 --- a/dashboard/tests.py +++ b/dashboard/tests.py @@ -63,7 +63,7 @@ def setUp(self): phone='+49 178 236 5288', gender=Gender.objects.first(), address='Schulstrasse 9', city='Munich', state='BA', zip_code='63108', pcp_preferred_zip='63018', - date_of_birth=datetime.date(1994, 01, 22), + date_of_birth=datetime.date(1994, 1, 22), patient_comfortable_with_english=False, preferred_contact_method=ContactMethod.objects.first(), ) @@ -102,7 +102,7 @@ def test_pt_without_note_and_pt_unsigned(self): phone='454545', gender=Gender.objects.first(), address='A', city='B', state='C', zip_code='12345', pcp_preferred_zip='12345', - date_of_birth=datetime.date(1992, 04, 22), + date_of_birth=datetime.date(1992, 4, 22), patient_comfortable_with_english=False, preferred_contact_method=ContactMethod.objects.first(), ) diff --git a/pttrack/test_views.py b/pttrack/test_views.py index 2252f32..2652ba1 100644 --- a/pttrack/test_views.py +++ b/pttrack/test_views.py @@ -1378,9 +1378,6 @@ def test_patient_detail(self): response = self.client.get(url) self.assertEqual(response.status_code, 200) - with open('tmp.html', 'w') as f: - f.write(response.content) - expected_status = "Action items 1, 0, 0 days past due" self.assertContains(response, expected_status) diff --git a/workup/admin.py b/workup/admin.py index 5ed037a..cb49f27 100644 --- a/workup/admin.py +++ b/workup/admin.py @@ -46,6 +46,3 @@ def view_on_site(self, obj): admin.site.register(model, SimpleHistoryAdmin) else: admin.site.register(model) - -for model in [models.Workup, models.ProgressNote]: - admin.site.register(model, NoteAdmin) diff --git a/workup/tests.py b/workup/tests.py index f4c29cf..e8402ab 100644 --- a/workup/tests.py +++ b/workup/tests.py @@ -104,9 +104,6 @@ def test_create_clindate(self): reverse('new-clindate', args=(pt.id,)), {'clinic_type': models.ClinicType.objects.first().pk}) - with open('tmp.html', 'w') as f: - f.write(r.content) - self.assertRedirects(r, reverse('new-workup', args=(pt.id,))) self.assertEqual(models.ClinicDate.objects.count(), 1) From f5dabc99cbfd08eb86e42a0ab42327c496fa5c09 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Tue, 22 Oct 2019 21:21:14 -0500 Subject: [PATCH 04/12] fix string decoding issues. --- dashboard/tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dashboard/tests.py b/dashboard/tests.py index 066e1ff..854f971 100644 --- a/dashboard/tests.py +++ b/dashboard/tests.py @@ -159,7 +159,7 @@ def test_dashboard_pagination(self):
  • '''), - dewhitespace(response.content)) + dewhitespace(response.content.decode('ascii'))) # since there's only one page, the "forward" pagination button # should be disabled self.assertIn( @@ -167,7 +167,7 @@ def test_dashboard_pagination(self):
  • '''), - dewhitespace(response.content)) + dewhitespace(response.content.decode('ascii'))) # since there's only one page, only one page marker should be shown self.assertContains( @@ -206,7 +206,7 @@ def test_dashboard_pagination(self):
  • '''), - dewhitespace(response.content)) + dewhitespace(response.content.decode('ascii'))) # since there's only one page, the "forward" pagination button # should be disabled self.assertIn( @@ -214,7 +214,7 @@ def test_dashboard_pagination(self):
  • '''), - dewhitespace(response.content)) + dewhitespace(response.content.decode('ascii'))) @override_settings(OSLER_CLINIC_DAYS_PER_PAGE=3) def test_dashboard_page_out_of_range(self): @@ -253,7 +253,7 @@ def test_dashboard_page_out_of_range(self):
  • '''), - dewhitespace(response.content)) + dewhitespace(response.content.decode('ascii'))) From fda939fe8a86210c5bfb5f58c899d0d6f62cd932 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Mon, 28 Oct 2019 21:03:14 -0500 Subject: [PATCH 05/12] manually install chrome stable. --- .circleci/config.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6c4da6c..e1b77ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,10 +2,14 @@ version: 2 jobs: build: docker: - - image: circleci/python:3.6.8-jessie-browsers + - image: circleci/python:3.6.8-jessie steps: - checkout - run: mkdir test-reports + - run: + name: Install Chrome + command: | + apt-get install -y google-chrome-stable & google-chrome --version - run: name: Download Selenium command: | From 4ca35a1a2224ecf964147ddc75a83a13c3058035 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Tue, 29 Oct 2019 00:14:26 -0500 Subject: [PATCH 06/12] remove google-chrome --version --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e1b77ed..17a33e3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ jobs: - run: name: Install Chrome command: | - apt-get install -y google-chrome-stable & google-chrome --version + apt-get install -y google-chrome-stable - run: name: Download Selenium command: | From 45257ff6e6a16a055efda07fea9dca20dd604d6c Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Tue, 29 Oct 2019 00:15:29 -0500 Subject: [PATCH 07/12] sudo chrome installation --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 17a33e3..10f595a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ jobs: - run: name: Install Chrome command: | - apt-get install -y google-chrome-stable + sudo apt-get install -y google-chrome-stable - run: name: Download Selenium command: | From cdd788800e0b01eeffe41b2b2cd9490f24578e56 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Tue, 29 Oct 2019 00:18:29 -0500 Subject: [PATCH 08/12] remove chrome changes. --- .circleci/config.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 10f595a..6c4da6c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,14 +2,10 @@ version: 2 jobs: build: docker: - - image: circleci/python:3.6.8-jessie + - image: circleci/python:3.6.8-jessie-browsers steps: - checkout - run: mkdir test-reports - - run: - name: Install Chrome - command: | - sudo apt-get install -y google-chrome-stable - run: name: Download Selenium command: | From 1f764ec6b9d459b5e4e4382d6da9d3f0f9255f93 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Mon, 4 Nov 2019 21:57:43 -0600 Subject: [PATCH 09/12] bump tested python version --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6c4da6c..1d73dbe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: docker: - - image: circleci/python:3.6.8-jessie-browsers + - image: circleci/python:3.7.5-jessie-browsers steps: - checkout - run: mkdir test-reports From fb62eeafb6f8ba196c45e8a490f12bcbfe7be3ef Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Mon, 4 Nov 2019 22:01:35 -0600 Subject: [PATCH 10/12] switch jessie for buster --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1d73dbe..2cf2006 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: docker: - - image: circleci/python:3.7.5-jessie-browsers + - image: circleci/python:3.7.5-buster-browsers steps: - checkout - run: mkdir test-reports From 7f20756deb0a2b6333a09206ee03419b4ab170c5 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Mon, 4 Nov 2019 22:04:31 -0600 Subject: [PATCH 11/12] try stretch on 3.6 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2cf2006..b4e9d94 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: build: docker: - - image: circleci/python:3.7.5-buster-browsers + - image: circleci/python:3.6.8-stretch-browsers steps: - checkout - run: mkdir test-reports From d707cc8ed373f0da62699928a6716b5f107cbc67 Mon Sep 17 00:00:00 2001 From: "Justin R. Porter" Date: Mon, 4 Nov 2019 22:10:22 -0600 Subject: [PATCH 12/12] try to set w3c compatibility checking to false. --- pttrack/test.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pttrack/test.py b/pttrack/test.py index b76bcc7..43438cb 100644 --- a/pttrack/test.py +++ b/pttrack/test.py @@ -1,6 +1,6 @@ from django.contrib.staticfiles.testing import StaticLiveServerTestCase -from selenium.webdriver.chrome.webdriver import WebDriver +from selenium.webdriver.chrome import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC @@ -13,7 +13,12 @@ class SeleniumLiveTestCase(StaticLiveServerTestCase): @classmethod def setUpClass(cls): super(SeleniumLiveTestCase, cls).setUpClass() - cls.selenium = WebDriver() + + opt = webdriver.ChromeOptions() + opt.add_experimental_option('w3c', False) + cls.selenium = webdriver.Chrome(chrome_options=opt) + + # cls.selenium = WebDriver() cls.selenium.implicitly_wait(cls.DEFAULT_WAIT_TIME) cls.selenium.set_page_load_timeout(cls.DEFAULT_WAIT_TIME)