Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Go to python 3 (trial 2) #213

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/python:2.7.15-jessie-browsers
- image: circleci/python:3.6.8-stretch-browsers
steps:
- checkout
- run: mkdir test-reports
Expand Down
82 changes: 46 additions & 36 deletions api/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ 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_type=workupModels.ClinicType.objects.first(),
clinic_date=now().date() + datetime.timedelta(days=1))
workupModels.ClinicDate.objects.create(
clinic_type=workupModels.ClinicType.objects.all()[0],
clinic_type=workupModels.ClinicType.objects.first(),
clinic_date=now().date() - datetime.timedelta(days=1))
workupModels.ClinicDate.objects.create(
clinic_type=workupModels.ClinicType.objects.all()[0],
clinic_type=workupModels.ClinicType.objects.first(),
clinic_date=now().date() - datetime.timedelta(days=5))

log_in_provider(self.client, build_provider(["Attending"]))

pt1 = models.Patient.objects.get(pk=1)
Expand All @@ -41,52 +42,52 @@ 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(
first_name="Asdf",
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(
first_name="No",
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.
Expand All @@ -96,8 +97,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)


Expand All @@ -108,38 +109,38 @@ 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(
short_name="Attending")[0])[0])

# 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,
patient=pt1)

# 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,
patient=pt2)

# 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)
Expand All @@ -149,16 +150,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
Expand All @@ -167,9 +171,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
Expand Down Expand Up @@ -225,7 +235,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
Expand Down
2 changes: 1 addition & 1 deletion appointment/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Meta:

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(),
Expand Down
2 changes: 1 addition & 1 deletion appointment/templates/appointment/appointment_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1>Appointment List</h1>

{% block content %}
<div class="container">
{% for date, app_list in appointments_by_date.iteritems %}
{% for date, app_list in appointments_by_date.items %}
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default {% if forloop.first %} panel-primary {%else%} panel-info {%endif%}"
Expand Down
12 changes: 6 additions & 6 deletions appointment/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_mark_noshow(self):
re.escape('href="/appointment/') +
r'[0-9]+' +
re.escape('/noshow'),
response.content)
response.content.decode('utf-8'))
self.assertEqual(len(noshow_links), 0)

def test_mark_arrived(self):
Expand All @@ -104,9 +104,9 @@ def test_mark_arrived(self):
# one 'mark as arrived' link should be gone now
arrived_links = re.findall(
re.escape('href="/appointment/') +
r'[0-9]+' +
'[0-9]+' +
re.escape('/arrived'),
response.content)
response.content.decode('utf-8'))

self.assertEqual(len(arrived_links), 0)

Expand Down Expand Up @@ -145,7 +145,7 @@ def test_first_apt_is_today(self):
new_appointment_links = re.findall(
re.escape('href="/appointment/new?date=') +
r'[0-9]{4}-[0-9]{2}-[0-9]{2}',
response.content)
response.content.decode('utf-8'))

self.assertEqual(len(new_appointment_links), 1)

Expand All @@ -155,7 +155,7 @@ def test_first_apt_is_today(self):
re.escape('href="/appointment/') +
r'[0-9]+' +
re.escape('/noshow'),
response.content)
response.content.decode('utf-8'))

self.assertEqual(len(noshow_links), 1)

Expand All @@ -165,6 +165,6 @@ def test_first_apt_is_today(self):
re.escape('href="/appointment/') +
r'[0-9]+' +
re.escape('/arrived'),
response.content)
response.content.decode('utf-8'))

self.assertEqual(len(arrived_links), 1)
2 changes: 1 addition & 1 deletion audit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ class PageviewRecord(models.Model):

timestamp = models.DateTimeField(auto_now_add=True)

def __unicode__(self):
def __str__(self):
return '%s by %s to %s at %s' % (self.method, self.user, self.url,
self.timestamp)
16 changes: 8 additions & 8 deletions dashboard/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
Expand Down Expand Up @@ -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(),
)
Expand Down Expand Up @@ -159,15 +159,15 @@ def test_dashboard_pagination(self):
<li class="disabled"><a aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a></li>'''),
dewhitespace(response.content))
dewhitespace(response.content.decode('ascii')))
# since there's only one page, the "forward" pagination button
# should be disabled
self.assertIn(
dewhitespace('''
<li class="disabled"> <a aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a> </li>'''),
dewhitespace(response.content))
dewhitespace(response.content.decode('ascii')))

# since there's only one page, only one page marker should be shown
self.assertContains(
Expand Down Expand Up @@ -206,15 +206,15 @@ def test_dashboard_pagination(self):
<li class="disabled"><a aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a></li>'''),
dewhitespace(response.content))
dewhitespace(response.content.decode('ascii')))
# since there's only one page, the "forward" pagination button
# should be disabled
self.assertIn(
dewhitespace('''
<li><a href="?page=2" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a></li>'''),
dewhitespace(response.content))
dewhitespace(response.content.decode('ascii')))

@override_settings(OSLER_CLINIC_DAYS_PER_PAGE=3)
def test_dashboard_page_out_of_range(self):
Expand Down Expand Up @@ -253,12 +253,12 @@ def test_dashboard_page_out_of_range(self):
<a href="?page=%s" aria-label="Previous">
<span aria-hidden="true">&laquo;
''' % n_pages),
dewhitespace(response.content))
dewhitespace(response.content.decode('ascii')))
# since there's only one page, the "forward" pagination button
# should be disabled
self.assertIn(
dewhitespace('''
<li class="disabled"> <a aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a> </li>'''),
dewhitespace(response.content))
dewhitespace(response.content.decode('ascii')))
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

class Migration(migrations.Migration):

replaces = [(b'demographics', '0001_initial'), (b'demographics', '0002_auto_20160328_1425'), (b'demographics', '0003_auto_20170623_1048')]
replaces = [('demographics', '0001_initial'),
('demographics', '0002_auto_20160328_1425'),
('demographics', '0003_auto_20170623_1048')]

dependencies = [
('pttrack', '0001_squashed_0010_auto_20170623_1300'),
Expand Down Expand Up @@ -70,7 +72,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='demographics',
name='chronic_condition',
field=models.ManyToManyField(to=b'demographics.ChronicCondition', blank=True),
field=models.ManyToManyField(to='demographics.ChronicCondition', blank=True),
),
migrations.AddField(
model_name='demographics',
Expand All @@ -85,7 +87,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='demographics',
name='resource_access',
field=models.ManyToManyField(to=b'demographics.ResourceAccess', verbose_name=b'Access to Resources', blank=True),
field=models.ManyToManyField(to='demographics.ResourceAccess', verbose_name=b'Access to Resources', blank=True),
),
migrations.AddField(
model_name='demographics',
Expand Down
Loading