def test_sort_resources(folder_with_two_files, sorting_type): folder, *_ = folder_with_two_files response = helper.get_resources_response(params=dict(path=folder, sort=sorting_type)) check.response_has_status_code(response, 200) check.response_has_fields(response, '_embedded') with allure.step("Check sorting is correct"): json = response.json() embedded = json['_embedded'] items = embedded['items'] expected_items = sorted(items, key=lambda item: item[sorting_type]) assert items == expected_items
def test_limit_nested_resources(folder_with_two_files, limit, expected_items, expected_limit): folder, *_ = folder_with_two_files response = helper.get_resources_response(params=dict(path=folder, limit=limit)) check.response_has_status_code(response, 200) check.response_has_fields(response, '_embedded') with allure.step("Check expected amount of resources were given"): json = response.json() embedded = json['_embedded'] assert len(embedded.get('items')) == expected_items assert embedded.get('limit') == expected_limit
def test_meta_for_file(module_file): path, file_name = module_file response = helper.get_resources_response(params=dict(path=path)) check.response_has_status_code(response, 200) check.response_has_fields( response, 'antivirus_status', 'file', 'sha256', 'name', 'exif', 'created', 'resource_id', 'modified', 'path', 'comment_ids', 'type', 'revision', 'media_type', 'md5', 'mime_type', 'size' ) check.response_has_field_with_value(response, "type", 'file') check.response_has_field_with_value(response, "mime_type", 'text/plain') check.response_has_field_with_value(response, "name", file_name)
def test_offset_nested_resources(folder_with_two_files): folder, file_1, file_2, *_ = folder_with_two_files response = helper.get_resources_response(params=dict(path=folder, offset=1, sort='created')) check.response_has_status_code(response, 200) check.response_has_fields(response, '_embedded') with allure.step("Check expected amount of files"): json = response.json() embedded = json['_embedded'] items = embedded.get('items') assert len(items) == 1, "Should be only one file (2 files in directory and offset is 1)" with allure.step("Check expected file is taken"): item = items[0] assert file_2 in item['path'], "Files should be sorted by created date (default sorting type)"
def test_upload_file_with_type(base_folder, file_name, link, mime_type): """ Temporary folder is created, upload in it image, operation should be successful, file should be available and have expected name and mime type """ file_path = f'{base_folder}/{file_name}' response = helper.post_upload_resource_response( params=dict(path=file_path, url=link)) check.response_has_status_code(response, 202) check.response_has_fields(response, 'href') href = response.json().get('href') operation_id = href.split('/')[-1] helper.when_operation_status(operation_id, 'success') with allure.step("File information should be available"): response = helper.get_resources_response(params=dict(path=file_path)) check.response_has_status_code(response, 200) check.response_has_field_with_value(response, "mime_type", mime_type) check.response_has_field_with_value(response, "name", file_name)
def test_get_disk_info(): response = helper.get_disk_info_response() check.response_has_status_code(response, 200) check.response_has_fields(response, 'system_folders', 'user', 'max_file_size', 'is_paid', 'used_space')