diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d57f810c..e4741c72 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,4 +2,4 @@ # How to test? -# Trello +# Jira diff --git a/application/controllers/collection_instrument.py b/application/controllers/collection_instrument.py index b194132f..f85030c4 100644 --- a/application/controllers/collection_instrument.py +++ b/application/controllers/collection_instrument.py @@ -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) diff --git a/tests/controllers/test_collection_instrument.py b/tests/controllers/test_collection_instrument.py index dc3cf299..be5b1a68 100644 --- a/tests/controllers/test_collection_instrument.py +++ b/tests/controllers/test_collection_instrument.py @@ -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)