Skip to content

Commit

Permalink
packs/GoogleDrive: rename test files
Browse files Browse the repository at this point in the history
Signed-off-by: Gal Nakash <gal@recolabs.ai>
  • Loading branch information
GalNakash-RecoLabs committed Aug 20, 2023
1 parent 7a38f7e commit 98eadc4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
31 changes: 23 additions & 8 deletions Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
'EXCEPTION_GENERIC': 'Exception handling a {} request: {}',
'MODIFY_LABEL_SUCCESS': 'Modify label successfully assigned to {}.',
'GET_LABEL_SUCCESS': 'Label successfully retrieved.',
'GET_LABELS_SUCCESS': 'Labels successfully retrieved.',
}

SCOPES: dict[str, list[str]] = {
Expand Down Expand Up @@ -152,7 +153,7 @@
'GOOGLE_DRIVE_FILE_PERMISSION_HEADER': 'GoogleDrive.FilePermission',
'FILE_PERMISSION': 'FilePermission',

'LABELS': 'DriveLabels'
'LABELS': 'GoogleDrive.Labels'

}

Expand Down Expand Up @@ -1240,9 +1241,12 @@ def modify_label_command(client: 'GSuiteClient', args: dict[str, str]) -> Comman
response,
headerTransform=pascalToSpace,
removeNull=False)
outputs_context = {
OUTPUT_PREFIX['LABELS']: response
}

return CommandResults(
outputs=response,
outputs=outputs_context,
readable_output=table_hr_md,
)

Expand All @@ -1256,13 +1260,22 @@ def get_file_labels_command(client: 'GSuiteClient', args: dict[str, str]) -> Com

response = client.http_request(url_suffix=url_suffix, method='GET', params=http_request_params)

outputs_context = {
OUTPUT_PREFIX['LABELS']: response,
OUTPUT_PREFIX['GOOGLE_DRIVE_FILE_HEADER']: {
OUTPUT_PREFIX['FILE']: {
'id': args.get('file_id'),
},
}
}

table_hr_md = tableToMarkdown(HR_MESSAGES['GET_LABEL_SUCCESS'].format(args.get('file_id')),
response,
response['labels'],
headerTransform=pascalToSpace,
removeNull=False)

return CommandResults(
outputs=response,
outputs=outputs_context,
readable_output=table_hr_md,
)

Expand All @@ -1280,11 +1293,13 @@ def get_labels_command(client: 'GSuiteClient', args: dict[str, str]) -> CommandR
OUTPUT_PREFIX['LABELS']: response
}

outputs: dict = {
OUTPUT_PREFIX['GOOGLE_DRIVE_DRIVE_HEADER']: outputs_context
}
table_hr_md = tableToMarkdown(HR_MESSAGES['GET_LABELS_SUCCESS'],
response['labels'],
headerTransform=pascalToSpace,
removeNull=False)
return CommandResults(
outputs=outputs
readable_output=table_hr_md,
outputs=outputs_context
)


Expand Down
16 changes: 6 additions & 10 deletions Packs/GoogleDrive/Integrations/GoogleDrive/GoogleDrive_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,16 +785,14 @@ def test_list_labels(self, mocker_http_request, gsuite_client):
"""
from GoogleDrive import get_labels_command

with open('test_data/list_labels_response.json.json', encoding='utf-8') as data:
with open('test_data/list_labels_response.json', encoding='utf-8') as data:
mock_response = json.load(data)
mocker_http_request.return_value = mock_response

result = get_labels_command(gsuite_client, {})

assert 'GoogleDrive.Drive.DriveLabels' in result.outputs
assert len(result.outputs['GoogleDrive.Drive.DriveLabels']) == 1

assert result.raw_response == mock_response
assert 'GoogleDrive.Drive' in result.outputs
assert len(result.outputs['GoogleDrive.Drive']['DriveLabels']) == 1


@patch(MOCKER_HTTP_METHOD)
Expand All @@ -813,15 +811,15 @@ def test_modify_labels_command(self, mocker_http_request, gsuite_client):
"""
from GoogleDrive import modify_label_command

with open('test_data/modify_label_command_repsonse.json.json', encoding='utf-8') as data:
with open('test_data/modify_label_command_response.json', encoding='utf-8') as data:
mock_response = json.load(data)
mocker_http_request.return_value = mock_response

args = {
'field_id': 'test',
'selection_label_id': 'test',
'label_id': 'test',
'file_id' : 'test'
'file_id': 'test'
}
result = modify_label_command(gsuite_client, args)

Expand All @@ -832,7 +830,6 @@ def test_modify_labels_command(self, mocker_http_request, gsuite_client):

assert HR_MESSAGES['MODIFY_LABEL_SUCCESS'].format(args.get('file_id')) in result.readable_output


@patch(MOCKER_HTTP_METHOD)
def test_file_permission_list_command_failure(self, mocker_http_request, gsuite_client):
"""
Expand Down Expand Up @@ -1001,8 +998,7 @@ def test_upload_file_with_parent_command_success(self, mocker, gsuite_client):
args = {
'parent': 'test_parent',
'entry_id': 'test_entry_id',
'file_name': 'test_file_name',
'parent': 'test_parent'
'file_name': 'test_file_name'

}
file_upload_command(gsuite_client, args)
Expand Down

0 comments on commit 98eadc4

Please sign in to comment.