Skip to content

Commit

Permalink
merges in v0.11.1 and adds in test on windows as a step for the release
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Jun 29, 2018
2 parents f303aac + dbf5ae0 commit 3caebb4
Show file tree
Hide file tree
Showing 24 changed files with 245 additions and 136 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ python:
- "3.4"
- "3.5"
- "3.6"
services:
- postgresql
install:
- python setup.py develop
- gem install coveralls-lcov
Expand All @@ -13,6 +15,7 @@ install:
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- psql -c 'create database travis_ci_test;' -U postgres
script:
- opal test --coverage
- flake8
Expand Down
16 changes: 12 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
### 0.12.0 (Major Release)

#### Misc Changes

* Adds a method `.demographics()` to `opal.models.Patient` which returns the relevant demographics instance.

### 0.11.1 (Minor bug fix)
Fixes the user_options in the date picker tag to display the options as part of the text input.

### 0.11.0 (Major Release)

#### Adds options of `today` and `yesterday` in the date picker
If you pass in `user_options=True` to the date picker. You will be provided with options to select today or yesterday in the form tag.

If you pass in `user_options=True` to the date picker. You will be provided with
options to select today or yesterday in the form tag.

#### Adds `dateHelper` to the rootScope

The dateHelper has the functions `now` and `yesterday` that return javascript Dates for
the current time and the current time - 1 day.

Expand All @@ -24,11 +33,13 @@ Fixes a bug whereby episodes were serialising differently depending on whether
the code path went via `.to_dict()` or `.objects.serialised()`.

#### HelpTextStep can now use a custom template

The `opal.core.pathway.steps.HelpTextStep` can now have a `help_text_template` passed in.

This is the template for what will be placed in the side bar.

#### Adds in a radio_vertical template tag

This displays the label and then the radio
buttons as a vertical list.

Expand Down Expand Up @@ -68,7 +79,6 @@ for a method named `get_$attr` and will call that if it exists.
Adds the method `.get_absolute_url()` to `opal.core.pathways.Pathway` and
`opal.core.patient_lists.PatientList`.


#### Template removals

We removed a number of superfluous templates:
Expand Down Expand Up @@ -99,11 +109,9 @@ override `base.html`in your application we advise that you add this `<meta>` tag
a generator function which will yield all subrecord singletons.
* Fixes a URI encoding bug in the `Episode.findByHospitalNumber()` method that
made hospital numbers including `#` or `/` raise an error.

* Adds the methods `.get_absolute_url()`, `.get_icon()` and `get_display_name()`
to `opal.core.pathways.Pathway` and `opal.core.patient_lists.PatientList`.


#### Updates to the Dependency Graph

* Django compressor: 1.5 -> 2.2
Expand Down
19 changes: 10 additions & 9 deletions doc/docs/guides/releasing.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
# Making a Release
1. Make and deploy a version to test it on a windows machines.

1. Tag the HEAD of the release branch and push to github: `git tag <version> && git push --tags`.
2. Tag the HEAD of the release branch and push to github: `git tag <version> && git push --tags`.
Opal branch names are in the format `vX.Y.Z` the tag for a release should be the `X.Y.Z` component
of the branch name.

1. Check version is correct in `_version.py`.
3. Check version is correct in `_version.py`.

1. Make sure you have `twine` installed and then: `make release`
4. Make sure you have `twine` installed and then: `make release`

1. Merge the branch you are releasing into `master`
5. Merge the branch you are releasing into `master`

1. Update the Github release page and make sure that it has the relevant Changelog contents.
6. Update the Github release page and make sure that it has the relevant Changelog contents.

1. If the branch for the next version does not already exist, create that branch. For instance, if you
7. If the branch for the next version does not already exist, create that branch. For instance, if you
have released `x.y.z` then create `x.y.(z+1)`. If you are creating a new version branch, ensure you have
also changed the version number in the documentation, `opal._version.__version__`, and the branches that
any badges in the project README are pointing at.

1. Change the github default branch to be the new in development version
8. Change the github default branch to be the new in development version

1. Update the Opal website: Change the current release and development version on the homepage, and run
9. Update the Opal website: Change the current release and development version on the homepage, and run
`rake docs` to regenerate the documentation site with a new latest stable release version.

1. Post to the Opal mailing list to announce the new release.
10. Post to the Opal mailing list to announce the new release.
6 changes: 5 additions & 1 deletion doc/docs/reference/patient.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

### methods

#### create_episode
#### `Patient.demographics()`

Returns the relevant Demographics instance for the patient.

#### `Patient.create_episode()`

Returns a new `Episode` for this patient.

Expand Down
2 changes: 1 addition & 1 deletion opal/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def create(self, request):
patient, created = Patient.objects.get_or_create(
demographics__hospital_number=hospital_number)
if created:
demographics = patient.demographics_set.get()
demographics = patient.demographics()
demographics.hospital_number = hospital_number
demographics.save()
else:
Expand Down
6 changes: 5 additions & 1 deletion opal/core/pathway/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ def test_integration(self, fake_pathway_get):
)
response = self.post_json(url, post_dict)
expected = {
'patient_id': 1, 'redirect_url': u'/#/patient/1/1', 'episode_id': 1
'patient_id': self.patient.id,
'redirect_url': u'/#/patient/{}/{}'.format(
self.patient.id, self.episode.id
),
'episode_id': self.episode.id
}
self.assertEqual(json.loads(response.content.decode('utf8')), expected)

Expand Down
35 changes: 22 additions & 13 deletions opal/core/pathway/tests/test_pathways.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RedirectsToPatientMixinTestCase(OpalTestCase):
def test_redirect(self):
p, e = self.new_patient_and_episode_please()
url = pathways.RedirectsToPatientMixin().redirect_url(patient=p)
self.assertEqual('/#/patient/1', url)
self.assertEqual('/#/patient/{}'.format(p.id), url)


class PathwayTestCase(OpalTestCase):
Expand Down Expand Up @@ -232,27 +232,36 @@ def test_new_patient_save(self):

def test_existing_patient_new_episode_save(self):
patient, episode = self.new_patient_and_episode_please()
demographics = patient.demographics_set.get()
demographics = patient.demographics()
demographics.hospital_number = "1231232"
demographics.save()

url = reverse(
"pathway", kwargs=dict(
name="dog_owner",
patient_id=1
patient_id=patient.id
)
)
self.post_data(url=url)
self.assertEqual(patient.episode_set.count(), 2)
self.assertEqual(DogOwner.objects.filter(episode_id=2).count(), 2)
self.assertFalse(DogOwner.objects.filter(episode_id=episode.id).exists())
new_episode = patient.episode_set.last()

# just validate that we definitely have created a new episode
self.assertNotEqual(episode.id, new_episode.id)

self.assertEqual(
DogOwner.objects.filter(episode_id=new_episode.id).count(), 2
)
self.assertFalse(
DogOwner.objects.filter(episode_id=episode.id).exists()
)

def test_users_patient_passed_in(self):
pathway = PagePathwayExample()
patient, episode = self.new_patient_and_episode_please()
post_data = {"demographics": [{"hospital_number": "101"}]}
pathway.save(data=post_data, user=self.user, patient=patient)
demographics = patient.demographics_set.get()
demographics = patient.demographics()
self.assertEqual(
demographics.hospital_number,
"101"
Expand All @@ -272,14 +281,14 @@ def test_users_episode_passed_in(self):

def test_existing_patient_existing_episode_save(self):
patient, episode = self.new_patient_and_episode_please()
demographics = patient.demographics_set.get()
demographics = patient.demographics()
demographics.hospital_number = "1231232"
demographics.save()
url = reverse(
"pathway", kwargs=dict(
name="dog_owner",
episode_id=1,
patient_id=1
episode_id=episode.id,
patient_id=patient.id
)
)
self.post_data(url=url)
Expand Down Expand Up @@ -309,7 +318,7 @@ def setUp(self):
def test_dont_update_subrecords_that_havent_changed(self, subrecords):
subrecords.return_value = [Colour]
colour = Colour.objects.create(
consistency_token="unchanged",
consistency_token="unchange",
name="Red",
episode=self.episode,
created=timezone.now()
Expand Down Expand Up @@ -340,7 +349,7 @@ def test_save_new_subrecords(self, subrecords):
def test_update_changed_subrecords(self, subrecords):
subrecords.return_value = [Colour]
colour = Colour.objects.create(
consistency_token="unchanged",
consistency_token="unchange",
name="Blue",
episode=self.episode,
)
Expand All @@ -365,12 +374,12 @@ def test_update_changed_subrecords(self, subrecords):
def test_only_change_one_in_a_list(self, subrecords):
subrecords.return_value = [Colour]
colour_1 = Colour.objects.create(
consistency_token="unchanged",
consistency_token="unchange",
name="Blue",
episode=self.episode,
)
colour_2 = Colour.objects.create(
consistency_token="unchanged",
consistency_token="unchange",
name="Orange",
episode=self.episode,
)
Expand Down
4 changes: 3 additions & 1 deletion opal/core/search/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, episode):
self.episode_ids = set([episode.id])
self.patient_id = episode.patient.id
self.categories = set([episode.category_name])
self.id = episode.patient.demographics_set.get().id
self.id = episode.patient.demographics().id

def update(self, episode):
if not self.start:
Expand Down Expand Up @@ -421,6 +421,8 @@ def get_aggregate_patients_from_episodes(self, episodes):

for patient_id, patient_summary in patient_summaries.items():
patient = next(p for p in patients if p.id == patient_id)
# Explicitly not using the .demographics property for performance
# note that we prefetch demographics_set a few lines earlier
demographic = patient.demographics_set.get()

result = {k: getattr(demographic, k) for k in [
Expand Down
27 changes: 20 additions & 7 deletions opal/core/search/tests/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ def test_get_row(self):
self.episode.set_tag_names(["trees"], self.user)
# make sure we keep historic tags
self.episode.set_tag_names(["leaves"], self.user)
self.assertIn("trees;leaves", renderer.get_row(self.episode))
row = renderer.get_row(self.episode)
self.assertTrue(
"trees;leaves" in row or "leaves;trees" in row
)


@patch.object(PatientColour, "_get_fieldnames_to_extract")
Expand All @@ -381,6 +384,8 @@ def setUp(self):
self.patient_colour = PatientColour.objects.create(
name="blue", patient=self.patient
)
self.pid_str = str(self.patient.id)
self.eid_str = str(self.episode.id)

def test_get_header(self, field_names_to_extract):
field_names_to_extract.return_value = [
Expand All @@ -403,7 +408,9 @@ def test_get_row(self, field_names_to_extract):
self.user
)
rendered = renderer.get_row(self.patient_colour, self.episode.id)
self.assertEqual(["1", "1", "blue"], rendered)
self.assertEqual(
[str(self.episode.id), str(self.patient.id), "blue"], rendered
)

def test_get_rows(self, field_names_to_extract):
field_names_to_extract.return_value = [
Expand All @@ -417,10 +424,13 @@ def test_get_rows(self, field_names_to_extract):
rendered = list(
renderer.get_rows()
)
self.assertEqual([["1", "1", "blue"]], rendered)
expected = [[self.eid_str, self.pid_str, "blue"]]
self.assertEqual(expected, rendered)

def test_get_rows_same_patient(self, field_names_to_extract):
self.patient.create_episode()
first_episode = self.patient.episode_set.first()
last_episode = self.patient.episode_set.last()
field_names_to_extract.return_value = [
"patient_id", "name", "consistency_token", "id"
]
Expand All @@ -434,18 +444,20 @@ def test_get_rows_same_patient(self, field_names_to_extract):
renderer.get_rows()
)
self.assertEqual([
["1", "1", "blue"],
["2", "1", "blue"]
[str(first_episode.id), str(self.patient.id), "blue"],
[str(last_episode.id), str(self.patient.id), "blue"]
], rendered)


@patch.object(Colour, "_get_fieldnames_to_extract")
class TestEpisodeSubrecordCsvRenderer(PatientEpisodeTestCase):
def setUp(self):
_, self.episode = self.new_patient_and_episode_please()
self.patient, self.episode = self.new_patient_and_episode_please()
self.colour = Colour.objects.create(
name="blue", episode=self.episode
)
self.eid_str = str(self.episode.id)
self.pid_str = str(self.patient.id)

def test_get_header(self, field_names_to_extract):
field_names_to_extract.return_value = [
Expand All @@ -466,7 +478,8 @@ def test_get_row(self, field_names_to_extract):
Colour, models.Episode.objects.all(), self.user
)
rendered = renderer.get_row(self.colour)
self.assertEqual(["1", "1", "blue"], rendered)
expected = [self.pid_str, self.eid_str, "blue"]
self.assertEqual(expected, rendered)


@patch('opal.core.search.extract.subrecords')
Expand Down
Loading

0 comments on commit 3caebb4

Please sign in to comment.