Skip to content

Commit 71bd74c

Browse files
committed
CON-337-fix(remote-rooms): return all rooms when there is no location
- return all rooms when the location is not available in the map filter [Delivers CON-337]
1 parent bac40b8 commit 71bd74c

File tree

4 files changed

+39
-29
lines changed

4 files changed

+39
-29
lines changed

api/room/schema_query.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@ def resolve_all_rooms(self, info, **kwargs):
280280
def resolve_all_remote_rooms(self, info, return_all=None):
281281
page_token = None
282282
filter = map_remote_room_location_to_filter()
283-
location = 'all' if return_all else get_user_from_db().location
283+
location = get_user_from_db().location
284+
if not filter.get(location) or return_all:
285+
location = 'all'
284286
remote_rooms = []
285287
while True:
286288
calendar_list = get_google_api_calendar_list(pageToken=page_token)

fixtures/room/query_room_fixtures.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,20 @@
1515
"data": {
1616
"allRemoteRooms": {
1717
"rooms": []
18-
}
1918
}
2019
}
20+
}
21+
22+
all_remote_rooms_with_argument_return_all_true_query = '''
23+
query{
24+
allRemoteRooms(returnAll: true){
25+
rooms{
26+
calendarId
27+
name
28+
}
29+
}
30+
}
31+
'''
2132

2233
paginated_rooms_query = '''
2334
query {

tests/base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,18 @@ def setUp(self, mock_verify_calendar_id):
211211
)
212212
structure.save()
213213
parent_node = OfficeStructure(
214-
id='C56A4180-65AA-42EC-A945-5FD21DEC0518',
215-
name='Epic Tower',
216-
tag='Lagos Building',
217-
location_id=1
214+
id='C56A4180-65AA-42EC-A945-5FD21DEC0518',
215+
name='Epic Tower',
216+
tag='Lagos Building',
217+
location_id=1
218218
)
219219
parent_node.save()
220220
child_node = OfficeStructure(
221-
id='C56A4180-65AA-42EC-A945-5FD21DEC0519',
222-
name='Gold Coast',
223-
tag='First Floor',
224-
parent_id='C56A4180-65AA-42EC-A945-5FD21DEC0518',
225-
location_id=1
221+
id='C56A4180-65AA-42EC-A945-5FD21DEC0519',
222+
name='Gold Coast',
223+
tag='First Floor',
224+
parent_id='C56A4180-65AA-42EC-A945-5FD21DEC0518',
225+
location_id=1
226226
)
227227
child_node.save()
228228
db_session.commit()

tests/test_rooms/test_query_rooms.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
room_query_with_non_existant_id_response,
1616
all_remote_rooms_query,
1717
paginated_rooms_query_blank_page,
18-
all_dummy_rooms_response
18+
all_dummy_rooms_response,
19+
all_remote_rooms_with_argument_return_all_true_query
1920
)
2021
from helpers.calendar.credentials import get_google_api_calendar_list
2122

@@ -52,23 +53,6 @@ def test_query_actual_remote_rooms(self, mock_get_json):
5253
"calendar.google.com"
5354
)
5455

55-
@patch("api.room.schema_query.get_google_api_calendar_list", spec=True,
56-
return_value=get_calendar_list_mock_data())
57-
def test_query_test_remote_rooms(self, mock_get_json):
58-
"""
59-
Mocks google calendar to return test rooms
60-
on the staging enviroment.
61-
Returns:
62-
- Test rooms
63-
Test rooms have the key words;
64-
- Test or Dummy
65-
"""
66-
CommonTestCases.admin_token_assert_equal(
67-
self,
68-
all_remote_rooms_query,
69-
all_dummy_rooms_response
70-
)
71-
7256
@patch("helpers.calendar.credentials.Credentials")
7357
def test_calendar_list_function(self, mocked_method):
7458
'''
@@ -78,6 +62,19 @@ def test_calendar_list_function(self, mocked_method):
7862
get_google_api_calendar_list()
7963
assert mocked_method.called
8064

65+
@patch("api.room.schema_query.get_google_api_calendar_list", spec=True,
66+
return_value=get_calendar_list_mock_data())
67+
def test_all_remote_rooms_with_argument_return_all_true(self, mock_get_json):
68+
"""
69+
returning all remote rooms with true as
70+
a value to the returnAll argument
71+
"""
72+
CommonTestCases.admin_token_assert_equal(
73+
self,
74+
all_remote_rooms_with_argument_return_all_true_query,
75+
all_dummy_rooms_response
76+
)
77+
8178
def test_query_room_with_id(self):
8279
response = self.app_test.post('/mrm?query='+room_query_by_id)
8380
actual_response = json.loads(response.data)

0 commit comments

Comments
 (0)