Skip to content

Commit

Permalink
Merge branch 'main' into cloud-sql-proxy-term-timeout-verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
LJBabbage authored Sep 8, 2023
2 parents db93378 + d916766 commit 4f49e0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 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: 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 4f49e0a

Please sign in to comment.