Skip to content

Commit

Permalink
Merge pull request #1579 from RignonNoel/new-develop
Browse files Browse the repository at this point in the history
fix bug for shared with self, update tests
  • Loading branch information
RignonNoel authored Sep 26, 2022
2 parents 9cabdfe + 569de97 commit faa50b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion retirement/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ def get_retreat_room_distribution(self):
# Handling friend pool
for key, value in friend_pool.items():
if not value['placed']:
if value['share_with'] in friend_pool:
if value['share_with'] in friend_pool and value['share_with'] != key:
if friend_pool[value['share_with']]['share_with'] == key:
room_number += 1
retreat_room_distribution.append(self._set_participant_room(
Expand Down
19 changes: 9 additions & 10 deletions retirement/tests/tests_model_Retreat.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_get_retreat_room_distribution(self):
metadata_1 = {"share_with_member": "[email protected]", "share_with_preferred_gender": "mixte"}
metadata_2 = {"share_with_member": "[email protected]", "share_with_preferred_gender": "man"}
metadata_3 = {"share_with_member": "", "share_with_preferred_gender": "woman"}
metadata_4 = {"share_with_member": "", "share_with_preferred_gender": "non-binary"}
metadata_4 = {"share_with_member": "[email protected]", "share_with_preferred_gender": "non-binary"}
metadata_5 = {"share_with_member": "", "share_with_preferred_gender": "non-binary"}
metadata_6 = {"share_with_member": "", "share_with_preferred_gender": "woman"}
metadata_7 = {"share_with_member": "", "share_with_preferred_gender": "non-binary"}
Expand Down Expand Up @@ -266,14 +266,14 @@ def test_get_retreat_room_distribution(self):
'gender_preference': 'man', 'share_with': '[email protected]', 'room_number': 4, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
'gender_preference': 'woman', 'share_with': '[email protected]', 'room_number': 4, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
'gender_preference': 'non-binary', 'share_with': 'NA', 'room_number': 5, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
'gender_preference': 'non-binary', 'share_with': 'NA', 'room_number': 5, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
'gender_preference': 'woman', 'share_with': 'NA', 'room_number': 6, 'placed': True},
'gender_preference': 'woman', 'share_with': 'NA', 'room_number': 5, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
'gender_preference': 'woman', 'share_with': 'NA', 'room_number': 6, 'placed': True},
'gender_preference': 'woman', 'share_with': 'NA', 'room_number': 5, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
'gender_preference': 'non-binary', 'share_with': 'NA', 'room_number': 6, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
'gender_preference': 'non-binary', 'share_with': 'NA', 'room_number': 6, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
'gender_preference': 'man', 'share_with': 'NA', 'room_number': 7, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
Expand All @@ -284,10 +284,9 @@ def test_get_retreat_room_distribution(self):
'gender_preference': 'man', 'share_with': 'NA', 'room_number': 8, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '[email protected]', 'room_option': 'shared',
'gender_preference': 'woman', 'share_with': 'NA', 'room_number': 9, 'placed': True},
{'first_name': 'x', 'last_name': 'y', 'email': '7@test.ca', 'room_option': 'shared',
'gender_preference': 'non-binary', 'share_with': 'NA', 'room_number': 9, 'placed': True}
{'first_name': 'x', 'last_name': 'y', 'email': '4@test.ca', 'room_option': 'shared',
'gender_preference': 'non-binary', 'share_with': '[email protected]', 'room_number': 9, 'placed': True}
]

self.assertEqual(len(distribution), 16)
self.assertEqual(distribution, expected_distribution)
room_set = set()
Expand Down

0 comments on commit faa50b7

Please sign in to comment.