Skip to content

CON-337 return all rooms when there is no location #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/room/schema_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ def resolve_all_rooms(self, info, **kwargs):
def resolve_all_remote_rooms(self, info, return_all=None):
page_token = None
filter = map_remote_room_location_to_filter()
location = 'all' if return_all else get_user_from_db().location
location = get_user_from_db().location
if not filter.get(location) or return_all:
location = 'all'
remote_rooms = []
while True:
calendar_list = get_google_api_calendar_list(pageToken=page_token)
Expand Down
13 changes: 12 additions & 1 deletion fixtures/room/query_room_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@
"data": {
"allRemoteRooms": {
"rooms": []
}
}
}
}

all_remote_rooms_with_argument_return_all_true_query = '''
query{
allRemoteRooms(returnAll: true){
rooms{
calendarId
name
}
}
}
'''

paginated_rooms_query = '''
query {
Expand Down
18 changes: 9 additions & 9 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,18 @@ def setUp(self, mock_verify_calendar_id):
)
structure.save()
parent_node = OfficeStructure(
id='C56A4180-65AA-42EC-A945-5FD21DEC0518',
name='Epic Tower',
tag='Lagos Building',
location_id=1
id='C56A4180-65AA-42EC-A945-5FD21DEC0518',
name='Epic Tower',
tag='Lagos Building',
location_id=1
)
parent_node.save()
child_node = OfficeStructure(
id='C56A4180-65AA-42EC-A945-5FD21DEC0519',
name='Gold Coast',
tag='First Floor',
parent_id='C56A4180-65AA-42EC-A945-5FD21DEC0518',
location_id=1
id='C56A4180-65AA-42EC-A945-5FD21DEC0519',
name='Gold Coast',
tag='First Floor',
parent_id='C56A4180-65AA-42EC-A945-5FD21DEC0518',
location_id=1
)
child_node.save()
db_session.commit()
Expand Down
34 changes: 16 additions & 18 deletions tests/test_rooms/test_query_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
room_query_with_non_existant_id_response,
all_remote_rooms_query,
paginated_rooms_query_blank_page,
all_dummy_rooms_response
all_dummy_rooms_response,
all_remote_rooms_with_argument_return_all_true_query
)
from helpers.calendar.credentials import get_google_api_calendar_list

Expand Down Expand Up @@ -52,23 +53,6 @@ def test_query_actual_remote_rooms(self, mock_get_json):
"calendar.google.com"
)

@patch("api.room.schema_query.get_google_api_calendar_list", spec=True,
return_value=get_calendar_list_mock_data())
def test_query_test_remote_rooms(self, mock_get_json):
"""
Mocks google calendar to return test rooms
on the staging enviroment.
Returns:
- Test rooms
Test rooms have the key words;
- Test or Dummy
"""
CommonTestCases.admin_token_assert_equal(
self,
all_remote_rooms_query,
all_dummy_rooms_response
)

@patch("helpers.calendar.credentials.Credentials")
def test_calendar_list_function(self, mocked_method):
'''
Expand All @@ -78,6 +62,20 @@ def test_calendar_list_function(self, mocked_method):
get_google_api_calendar_list()
assert mocked_method.called

@patch("api.room.schema_query.get_google_api_calendar_list", spec=True,
return_value=get_calendar_list_mock_data())
def test_all_remote_rooms_with_argument_return_all_true(self,
mock_get_json):
"""
returning all remote rooms with true as
a value to the returnAll argument
"""
CommonTestCases.admin_token_assert_equal(
self,
all_remote_rooms_with_argument_return_all_true_query,
all_dummy_rooms_response
)

def test_query_room_with_id(self):
response = self.app_test.post('/mrm?query='+room_query_by_id)
actual_response = json.loads(response.data)
Expand Down