diff --git a/retirement/models.py b/retirement/models.py index 5474351d..750c0585 100644 --- a/retirement/models.py +++ b/retirement/models.py @@ -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( diff --git a/retirement/tests/tests_model_Retreat.py b/retirement/tests/tests_model_Retreat.py index d38ff6b0..adc9ccb5 100644 --- a/retirement/tests/tests_model_Retreat.py +++ b/retirement/tests/tests_model_Retreat.py @@ -204,7 +204,7 @@ def test_get_retreat_room_distribution(self): metadata_1 = {"share_with_member": "14@test.ca", "share_with_preferred_gender": "mixte"} metadata_2 = {"share_with_member": "11@test.ca", "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": "4@test.ca", "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"} @@ -266,14 +266,14 @@ def test_get_retreat_room_distribution(self): 'gender_preference': 'man', 'share_with': '11@test.ca', 'room_number': 4, 'placed': True}, {'first_name': 'x', 'last_name': 'y', 'email': '11@test.ca', 'room_option': 'shared', 'gender_preference': 'woman', 'share_with': '2@test.ca', 'room_number': 4, 'placed': True}, - {'first_name': 'x', 'last_name': 'y', 'email': '5@test.ca', 'room_option': 'shared', - 'gender_preference': 'non-binary', 'share_with': 'NA', 'room_number': 5, 'placed': True}, - {'first_name': 'x', 'last_name': 'y', 'email': '4@test.ca', 'room_option': 'shared', - 'gender_preference': 'non-binary', 'share_with': 'NA', 'room_number': 5, 'placed': True}, {'first_name': 'x', 'last_name': 'y', 'email': '6@test.ca', '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': '3@test.ca', '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': '7@test.ca', 'room_option': 'shared', + 'gender_preference': 'non-binary', 'share_with': 'NA', 'room_number': 6, 'placed': True}, + {'first_name': 'x', 'last_name': 'y', 'email': '5@test.ca', 'room_option': 'shared', + 'gender_preference': 'non-binary', 'share_with': 'NA', 'room_number': 6, 'placed': True}, {'first_name': 'x', 'last_name': 'y', 'email': '9@test.ca', 'room_option': 'shared', 'gender_preference': 'man', 'share_with': 'NA', 'room_number': 7, 'placed': True}, {'first_name': 'x', 'last_name': 'y', 'email': '8@test.ca', 'room_option': 'shared', @@ -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': '13@test.ca', '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': '4@test.ca', 'room_number': 9, 'placed': True} ] - self.assertEqual(len(distribution), 16) self.assertEqual(distribution, expected_distribution) room_set = set()