Skip to content

Commit

Permalink
RAS-815: EQ_AND_SEFT when adding a eQ instruments SEFT ones will be r…
Browse files Browse the repository at this point in the history
…emoved (#313)

* Initial ccommit of fix for eQ CI removing SEFT CI

* auto patch increment

* Change Trello to Jira and revert config back

* Added test for code change

* Ran lint

* Removed redundent method

* I have tidied up the test

* Updated step info

* Have made the recommended alterations

---------

Co-authored-by: ras-rm-pr-bot <[email protected]>
  • Loading branch information
SteveScorfield and ras-rm-pr-bot authored Sep 5, 2023
1 parent 3476e63 commit d916766
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# How to test?

# Trello
# Jira
4 changes: 2 additions & 2 deletions _infra/helm/collection-instrument/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 3.0.19
version: 3.0.20

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 3.0.19
appVersion: 3.0.20

4 changes: 3 additions & 1 deletion application/controllers/collection_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ def update_exercise_eq_instruments(self, exercise_id: str, instruments: list, se

validate_uuid(exercise_id)
exercise = self._find_or_create_exercise(exercise_id, session)
current_instruments = [str(instrument.instrument_id) for instrument in exercise.instruments]
current_instruments = [
str(instrument.instrument_id) for instrument in exercise.instruments if instrument.type == "EQ"
]

instruments_to_add = set(instruments).difference(current_instruments)
instruments_to_remove = set(current_instruments).difference(instruments)
Expand Down
15 changes: 15 additions & 0 deletions tests/controllers/test_collection_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,21 @@ def test_get_instrument_by_incorrect_id(self):
# Then that instrument is not found
self.assertEqual(instrument, None)

def test_update_exercise_eq_instruments_doesnt_remove_seft(self):
# Given there is an instrument in the db for a SEFT
# When an eQ is added to collection exercise id
self._add_instrument_data(ci_type="EQ")

# Then the user unselects this eQ and exercise instrument is updated
self.collection_instrument.update_exercise_eq_instruments(COLLECTION_EXERCISE_ID, [])

# And the eQ is removed but the SEFT is still present
instrument = self.collection_instrument.get_instrument_json(str(self.instrument_id))

self.assertIn(str(self.instrument_id), json.dumps(str(instrument)))
self.assertIn("SEFT", json.dumps(str(instrument)))
self.assertNotIn("EQ", json.dumps(str(instrument)))

@with_db_session
def _add_instrument_data(self, session=None, ci_type="SEFT", exercise_id=COLLECTION_EXERCISE_ID):
instrument = InstrumentModel(ci_type=ci_type)
Expand Down

0 comments on commit d916766

Please sign in to comment.