def test_share_file_v2(self): file_name = 'test_file_share_file_v2_' + str(int(time())) + '.dwg' expected_code_and_description = (0, 'SUCCESS') user_name_to_share_with = 'rest_tests_share_with_user_' + str( int(time())) + '@autodesk.com' self.extra_data.add_test_data('file name', file_name) self.extra_data.add_test_data('user name to share with', user_name_to_share_with) login_data = self.main_register_and_login_mixin.login_or_register( user_name=user_name_to_share_with, password=self.password, first_name=self.first_name, last_name=self.last_name) auth_user_to_share_with = self.main_register_and_login_mixin.get_auth_from_login_data( login_data) self.assertIsInstance( auth_user_to_share_with, str, 'Invalid auth: ' + str(auth_user_to_share_with) + self.extra_data.get_all()) created_file_id, msg = TestUtils.create_file( auth=self.auth, file_name=file_name, extra_data=self.extra_data) self.assertIsNotNone(created_file_id, msg + self.extra_data.get_all()) share_response = self.files_management_client.share_file_v2( auth=self.auth, file_id=created_file_id, emails=[user_name_to_share_with]) status_code = ClientUtils.get_response_status_code(share_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'share_file response', ClientUtils.get_response_body(share_response)) code_desc = ClientUtils.get_code_and_description_from_response( share_response) self.assertEqual( expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_internal_partition( auth=auth_user_to_share_with, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) shared_file = TestUtils.get_entry_from_internal_file_system_entries( created_file_id, file_system_entries) self.assertIsNotNone( shared_file, 'Shared file should exist in partition' + self.extra_data.get_all())
def test_rename_folder_v2(self): folder_name = 'test_folder_rename_folder_v2_' + str(int(time())) folder_new_name = 'test_folder_rename_folder_v2_renamed_' + str( int(time())) expected_code_and_description = (0, 'SUCCESS') self.extra_data.add_test_data('folder name', folder_name) self.extra_data.add_test_data('folder new name', folder_new_name) created_folder_id, msg = TestUtils.create_folder( auth=self.auth, folder_name=folder_name, extra_data=self.extra_data) self.assertIsNotNone(created_folder_id, msg + self.extra_data.get_all()) rename_folder_response = self.folders_management_client.rename_folder_v2( auth=self.auth, folder_id=created_folder_id, name=folder_new_name) status_code = ClientUtils.get_response_status_code( rename_folder_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'rename_folder response', ClientUtils.get_response_body(rename_folder_response)) code_desc = ClientUtils.get_code_and_description_from_response( rename_folder_response) self.assertEqual( expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_internal_partition( auth=self.auth, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) entry = TestUtils.get_entry_from_internal_file_system_entries( created_folder_id, file_system_entries) self.assertIsNotNone( entry, 'Renamed folder should exist in partition' + self.extra_data.get_all()) partition_folder_name = TestUtils.get_entry_data_by_keys( entry=entry, keys=PartitionClient.KEY_ENTRY_NAME) self.assertEqual( folder_new_name, partition_folder_name, 'Expected folder name: ' + str(folder_new_name) + ' but got: ' + str(partition_folder_name) + self.extra_data.get_all())
def test_register_v1_empty_password(self): expected_code_and_description = (400, 'One or more parameters are missing.') response = self.register_client.register_v1(user_name=self.user_name, password=self.empty_password, first_name=self.first_name, last_name=self.last_name) status_code = ClientUtils.get_response_status_code(response) self.assertEqual(httplib.BAD_REQUEST, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data('register response', ClientUtils.get_response_body(response)) code_desc = ClientUtils.get_code_and_description_from_response(response) self.assertEqual(expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str( code_desc) + self.extra_data.get_all())
def test_register_v1_invalid_password(self): expected_code_and_description = (2, 'PASSWORD REJECTED') response = self.register_client.register_v1(user_name=self.user_name, password=self.invalid_password, first_name=self.first_name, last_name=self.last_name) status_code = ClientUtils.get_response_status_code(response) self.assertEqual(httplib.BAD_REQUEST, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data('register response', ClientUtils.get_response_body(response)) code_desc = ClientUtils.get_code_and_description_from_response(response) self.assertEqual(expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str( code_desc) + self.extra_data.get_all())
def create_external_folder(auth, host_id, folder_path, new_folder_name, extra_data): expected_code_and_description = (0, 'SUCCESS') folders_management_client = FoldersManagementClient() response = folders_management_client.create_external_folder_v2(auth=auth, host_id=host_id, folder_path=folder_path, new_folder_name=new_folder_name) status_code = ClientUtils.get_response_status_code(response) if not httplib.OK == status_code: return None, 'Expected status: ' + str(httplib.OK) + ' but got: ' + str(status_code) extra_data.add_test_data('create_external_folder response', ClientUtils.get_response_body(response)) code_and_description = ClientUtils.get_code_and_description_from_response(response) if not expected_code_and_description == code_and_description: return None, 'Expected code and description: ' + str(expected_code_and_description) + ' but got: ' + str( code_and_description) return True, ''
def test_delete_folder(self): folder_name = 'test_folder_delete_folder_' + str(int(time())) expected_code_and_description = (0, 'SUCCESS') self.extra_data.add_test_data('folder name', folder_name) created_folder_id, msg = TestUtils.create_folder( auth=self.auth, folder_name=folder_name, extra_data=self.extra_data) self.assertIsNotNone(created_folder_id, msg + self.extra_data.get_all()) delete_folder_response = self.folders_management_client.delete_folder( auth=self.auth, folder_id=created_folder_id) status_code = ClientUtils.get_response_status_code( delete_folder_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'delete_folder response', ClientUtils.get_response_body(delete_folder_response)) code_desc = ClientUtils.get_code_and_description_from_response( delete_folder_response) self.assertEqual( expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_internal_partition( auth=self.auth, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) entry = TestUtils.get_entry_from_internal_file_system_entries( created_folder_id, file_system_entries) self.assertIsNone( entry, 'Deleted folder should not exist in partition' + self.extra_data.get_all())
def create_folder(auth, folder_name, extra_data): expected_code_and_description = (0, 'SUCCESS') folders_management_client = FoldersManagementClient() response = folders_management_client.create_folder_v2(auth=auth, new_folder_name=folder_name) status_code = ClientUtils.get_response_status_code(response) if not httplib.OK == status_code: return None, 'Expected status: ' + str(httplib.OK) + ' but got: ' + str(status_code) extra_data.add_test_data('create_folder response', ClientUtils.get_response_body(response)) code_and_description = ClientUtils.get_code_and_description_from_response(response) if not expected_code_and_description == code_and_description: return None, 'Expected code and description: ' + str(expected_code_and_description) + ' but got: ' + str( code_and_description) created_folder_id = ClientUtils.get_value_from_body(response, FoldersManagementClient.KEY_FOLDER_ID) if not created_folder_id > 0: return None, 'Expected a valid folder id but got: ' + str(created_folder_id) extra_data.add_test_data('created folder id', created_folder_id) return created_folder_id, ''
def test_move_file_to_external_folder_rename_and_delete_it_v2(self): folder_name = 'test_folder_external_file_flow_' + str(int(time())) file_name = 'test_file_external_file_flow_' + str(int(time())) + '.dwg' file_new_name = 'test_file_external_file_flow_renamed_' + str( int(time())) + '.dwg' permanent_folder = 'Permanent_Folder/' self.extra_data.add_test_data('folder name', folder_name) self.extra_data.add_test_data('file name', file_name) self.extra_data.add_test_data('file new name', file_new_name) success_code_and_description = (0, 'SUCCESS') cont_async_code_and_description = ( 23, 'FILESYSTEM OPERATION CONTINUES ASYNCRONOUSLY') polling_timeout_in_seconds = 30 delay_between_polls = 1 success, msg = TestUtils.create_external_folder( auth=self.auth, host_id=self.host_id, folder_path=permanent_folder, new_folder_name=folder_name, extra_data=self.extra_data) self.assertIsNotNone(success, msg + self.extra_data.get_all()) folder_name = permanent_folder + folder_name self.extra_data.add_test_data('folder name', folder_name) created_file_id, msg = TestUtils.create_file( auth=self.auth, file_name=file_name, extra_data=self.extra_data) self.assertIsNotNone(created_file_id, msg + self.extra_data.get_all()) move_to_external_folder_response = self.files_management_client.move_internal_file_to_external( auth=self.auth, file_id=created_file_id, to_host_id=self.host_id, to_path=folder_name + '/') status_code = ClientUtils.get_response_status_code( move_to_external_folder_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'move_internal_file_to_external response', ClientUtils.get_response_body(move_to_external_folder_response)) code_desc = ClientUtils.get_code_and_description_from_response( move_to_external_folder_response) self.assertEqual( cont_async_code_and_description, code_desc, 'Expected ' + str(cont_async_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) polling_id = ClientUtils.get_value_from_body( move_to_external_folder_response, FilesManagementClient.KEY_POLLING_ID) self.assertTrue( polling_id > 0, 'Expected valid polling id, but got: ' + str(polling_id) + self.extra_data.get_all()) self.extra_data.add_test_data('polling id', polling_id) successful_move, msg = TestUtils.poll_for_move_to_external( auth=self.auth, polling_id=polling_id, sleep_period=delay_between_polls, timeout_in_seconds=polling_timeout_in_seconds, extra_data=self.extra_data) self.assertIsNotNone(successful_move, msg + self.extra_data.get_all()) sleep(5) file_system_entries, msg = TestUtils.get_external_partition( auth=self.auth, host_id=self.host_id, path=folder_name, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) file_system_entries_names = [ str(entry[self.partition_client.KEY_ENTRY_NAME]) for entry in file_system_entries if entry['type'] == 'EXTERNAL_DRAWING' ] if file_name not in file_system_entries_names: self.fail('New file should have been moved to external host' + self.extra_data.get_all()) internal_file_system_entries, msg = TestUtils.get_internal_partition( auth=self.auth, extra_data=self.extra_data) self.assertIsNotNone(internal_file_system_entries, msg + self.extra_data.get_all()) file_system_entries_names = [ str(entry[self.partition_client.KEY_ENTRY_NAME]) for entry in internal_file_system_entries if entry['type'] == 'DRAWING' ] if file_new_name in file_system_entries_names: self.fail( 'File should have moved to external folder, and not found in internal partition result' + self.extra_data.get_all()) file_relative_path = folder_name + '/' + file_name self.extra_data.add_test_data('file relative path', file_relative_path) rename_file_response = self.files_management_client.rename_external_file_v2( auth=self.auth, host_id=self.host_id, name=file_new_name, path=file_relative_path) status_code = ClientUtils.get_response_status_code( rename_file_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'rename_external_file response', ClientUtils.get_response_body(rename_file_response)) code_desc = ClientUtils.get_code_and_description_from_response( rename_file_response) self.assertEqual( success_code_and_description, code_desc, 'Expected ' + str(success_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_external_partition( auth=self.auth, host_id=self.host_id, path=folder_name, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) file_system_entries_names = [ str(entry[self.partition_client.KEY_ENTRY_NAME]) for entry in file_system_entries if entry['type'] == 'EXTERNAL_DRAWING' ] if file_new_name not in file_system_entries_names: self.fail('File should have been renamed in external host' + self.extra_data.get_all()) file_relative_path = folder_name + '/' + file_new_name self.extra_data.add_test_data('file relative path', file_relative_path) delete_file_response = self.files_management_client.delete_external_file_v2( auth=self.auth, host_id=self.host_id, path=file_relative_path) status_code = ClientUtils.get_response_status_code( delete_file_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'delete_external_file response', ClientUtils.get_response_body(delete_file_response)) code_desc = ClientUtils.get_code_and_description_from_response( delete_file_response) self.assertEqual( success_code_and_description, code_desc, 'Expected ' + str(success_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_external_partition( auth=self.auth, host_id=self.host_id, path=folder_name, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) file_system_entries_names = [ str(entry[self.partition_client.KEY_ENTRY_NAME]) for entry in file_system_entries if entry['type'] == 'EXTERNAL_DRAWING' ] if file_new_name in file_system_entries_names: self.fail( 'Folder should have been deleted, and not found in partition result' + self.extra_data.get_all()) # Teardown - remove created folder - does not affect test results self.folders_management_client.delete_external_folder_v2( auth=self.auth, host_id=self.host_id, path=folder_name)
def test_create_rename_and_delete_external_folder_v2(self): folder_name = 'test_folder_external_folder_flow_' + str(int(time())) folder_new_name = 'test_folder_external_folder_flow_renamed_' + str( int(time())) permanent_folder = 'Permanent_Folder/' expected_code_and_description = (0, 'SUCCESS') self.extra_data.add_test_data('folder name', folder_name) self.extra_data.add_test_data('folder new name', folder_new_name) create_folder_response = self.folders_management_client.create_external_folder_v2( auth=self.auth, host_id=self.host_id, new_folder_name=folder_name, folder_path=permanent_folder) status_code = ClientUtils.get_response_status_code( create_folder_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'create_external_folder response', ClientUtils.get_response_body(create_folder_response)) code_desc = ClientUtils.get_code_and_description_from_response( create_folder_response) self.assertEqual( expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_external_partition( auth=self.auth, host_id=self.host_id, path=permanent_folder, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) file_system_entries_names = [ str(entry[self.partition_client.KEY_ENTRY_NAME]) for entry in file_system_entries if entry['type'] == 'EXTERNAL_FOLDER' ] if folder_name not in file_system_entries_names: self.fail('Folder should have been created in external host' + self.extra_data.get_all()) new_folder_relative_path = permanent_folder + folder_name self.extra_data.add_test_data('new folder relative path', new_folder_relative_path) rename_folder_response = self.folders_management_client.rename_external_folder_v2( auth=self.auth, host_id=self.host_id, path=new_folder_relative_path, name=folder_new_name) status_code = ClientUtils.get_response_status_code( rename_folder_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'rename_external_folder response', ClientUtils.get_response_body(rename_folder_response)) code_desc = ClientUtils.get_code_and_description_from_response( rename_folder_response) self.assertEqual( expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_external_partition( auth=self.auth, host_id=self.host_id, path=permanent_folder, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) file_system_entries_names = [ str(entry[self.partition_client.KEY_ENTRY_NAME]) for entry in file_system_entries if entry['type'] == 'EXTERNAL_FOLDER' ] if folder_new_name not in file_system_entries_names: self.fail('Folder should have been renamed in external host' + self.extra_data.get_all()) renamed_folder_relative_path = permanent_folder + folder_new_name self.extra_data.add_test_data('renamed folder relative path', renamed_folder_relative_path) delete_folder_response = self.folders_management_client.delete_external_folder_v2( auth=self.auth, host_id=self.host_id, path=renamed_folder_relative_path) status_code = ClientUtils.get_response_status_code( delete_folder_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'delete_external_folder response', ClientUtils.get_response_body(delete_folder_response)) code_desc = ClientUtils.get_code_and_description_from_response( delete_folder_response) self.assertEqual( expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_external_partition( auth=self.auth, host_id=self.host_id, path=permanent_folder, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) file_system_entries_names = [ str(entry[self.partition_client.KEY_ENTRY_NAME]) for entry in file_system_entries if entry['type'] == 'EXTERNAL_FOLDER' ] if folder_new_name in file_system_entries_names: self.fail( 'Folder should have been deleted, and not found in partition result' + self.extra_data.get_all())
def test_share_folder_without_sharing_permissions(self): folder_name = 'test_folder_share_folder_without_permissions_' + str(int(time())) expected_code_and_description = (3, 'INSUFFICIENT PERMISSIONS') user_name_to_share_with = 'rest_tests_share_with_user' + str(int(time())) + '@autodesk.com' user_name_can_not_share_with = 'rest_tests_share_with_user_should_fail' + str(int(time())) + '@autodesk.com' self.extra_data.add_test_data('folder name', folder_name) self.extra_data.add_test_data('user name to share with', user_name_to_share_with) self.extra_data.add_test_data('user name can not share with', user_name_can_not_share_with) login_data = self.main_register_and_login.login_or_register(user_name=user_name_to_share_with, password=self.password, first_name=self.first_name, last_name=self.last_name) auth_user_to_share_with = self.main_register_and_login.get_auth_from_login_data(login_data) self.assertIsInstance(auth_user_to_share_with, str, 'Invalid auth: ' + str(auth_user_to_share_with) + self.extra_data.get_all()) login_data = self.main_register_and_login.login_or_register(user_name=user_name_can_not_share_with, password=self.password, first_name=self.first_name, last_name=self.last_name) auth_user_can_not_share_with = self.main_register_and_login.get_auth_from_login_data(login_data) self.assertIsInstance(auth_user_can_not_share_with, str, 'Invalid auth: ' + str(auth_user_can_not_share_with) + self.extra_data.get_all()) created_folder_id, msg = TestUtils.create_folder(auth=self.auth, folder_name=folder_name, extra_data=self.extra_data) self.assertIsNotNone(created_folder_id, msg + self.extra_data.get_all()) share_response = self.folders_management_client.share_folder(auth=self.auth, folder_id=created_folder_id, emails=[user_name_to_share_with], can_share=False) status_code = ClientUtils.get_response_status_code(share_response) self.assertEqual(httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data('share_folder response', ClientUtils.get_response_body(share_response)) file_system_entries, msg = TestUtils.get_internal_partition(auth=auth_user_to_share_with, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) shared_folder = TestUtils.get_entry_from_internal_file_system_entries(created_folder_id, file_system_entries) self.assertIsNotNone(shared_folder, 'Shared folders should exist in partition' + self.extra_data.get_all()) share_response = self.folders_management_client.share_folder(auth=auth_user_to_share_with, folder_id=created_folder_id, emails=[user_name_can_not_share_with]) status_code = ClientUtils.get_response_status_code(share_response) self.assertEqual(httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data('share_folder response', ClientUtils.get_response_body(share_response)) code_desc = ClientUtils.get_code_and_description_from_response(share_response) self.assertEqual(expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str( code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_internal_partition(auth=auth_user_can_not_share_with, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) shared_folder = TestUtils.get_entry_from_internal_file_system_entries(created_folder_id, file_system_entries) self.assertIsNone(shared_folder, 'Folder not shared due to missing permissions should not exist in partition' + self.extra_data.get_all())
def test_move_file_internal(self): expected_code_and_description = (0, 'SUCCESS') file_name = 'test_file_move_file_internal_' + str(int(time())) + '.dwg' folder_name = 'test_folder_move_file_internal_' + str(int(time())) self.extra_data.add_test_data('file name', file_name) self.extra_data.add_test_data('folder name', folder_name) created_folder_id, msg = TestUtils.create_folder( auth=self.auth, folder_name=folder_name, extra_data=self.extra_data) self.assertIsNotNone(created_folder_id, msg + self.extra_data.get_all()) created_file_id, msg = TestUtils.create_file( auth=self.auth, file_name=file_name, extra_data=self.extra_data) self.assertIsNotNone(created_file_id, msg + self.extra_data.get_all()) move_file_response = self.files_management_client.move_file_internal( auth=self.auth, file_id=created_file_id, to_folder_id=created_folder_id) status_code = ClientUtils.get_response_status_code(move_file_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'move_file_internal response', ClientUtils.get_response_body(move_file_response)) code_desc = ClientUtils.get_code_and_description_from_response( move_file_response) self.assertEqual( expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_internal_partition( auth=self.auth, partition_folder_id=created_folder_id, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) entry = TestUtils.get_entry_from_internal_file_system_entries( created_file_id, file_system_entries) self.assertIsNotNone( entry, 'File should have moved to the new folder' + self.extra_data.get_all()) partition_file_name = TestUtils.get_entry_data_by_keys( entry=entry, keys=PartitionClient.KEY_ENTRY_NAME) self.assertEqual( file_name, partition_file_name, 'Expected file name: ' + str(file_name) + ' but got: ' + str(partition_file_name) + self.extra_data.get_all()) file_system_entries, msg = TestUtils.get_internal_partition( auth=self.auth, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) entry = TestUtils.get_entry_from_internal_file_system_entries( created_file_id, file_system_entries) self.assertIsNone( entry, 'File should no longer appear in root folder' + self.extra_data.get_all())
def test_copy_file_v2_internal(self): file_name = 'test_file_copy_file_v2_internal_' + str(int( time())) + '.dwg' file_new_name = 'test_file_copy_file_v2_internal_copy' + str( int(time())) + '.dwg' expected_code_and_description = (0, 'SUCCESS') self.extra_data.add_test_data('file name', file_name) self.extra_data.add_test_data('file new name', file_new_name) created_file_id, msg = TestUtils.create_file( auth=self.auth, file_name=file_name, extra_data=self.extra_data) self.assertIsNotNone(created_file_id, msg + self.extra_data.get_all()) copy_file_response = self.files_management_client.copy_file_v2_internal( auth=self.auth, file_id=created_file_id, to_folder_id=0, rename_to=file_new_name) status_code = ClientUtils.get_response_status_code(copy_file_response) self.assertEqual( httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all()) self.extra_data.add_test_data( 'copy_file_internal response', ClientUtils.get_response_body(copy_file_response)) code_desc = ClientUtils.get_code_and_description_from_response( copy_file_response) self.assertEqual( expected_code_and_description, code_desc, 'Expected ' + str(expected_code_and_description) + ' but got: ' + str(code_desc) + self.extra_data.get_all()) copied_file_id = ClientUtils.get_value_from_body( copy_file_response, FilesManagementClient.KEY_PRIMARY_WS_ID) self.assertTrue( copied_file_id > 0, 'Expected valid copied file id but got: ' + str(copied_file_id) + self.extra_data.get_all()) self.extra_data.add_test_data('copied file id', copied_file_id) file_system_entries, msg = TestUtils.get_internal_partition( auth=self.auth, extra_data=self.extra_data) self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all()) entry_src = TestUtils.get_entry_from_internal_file_system_entries( entry_id=created_file_id, internal_file_system_entries=file_system_entries) entry_copy = TestUtils.get_entry_from_internal_file_system_entries( entry_id=copied_file_id, internal_file_system_entries=file_system_entries) self.assertIsNotNone( entry_src, 'Source file should still exist in partition' + self.extra_data.get_all()) self.assertIsNotNone( entry_copy, 'Copied file should exist in partition' + self.extra_data.get_all()) entry_src_name = TestUtils.get_entry_data_by_keys( entry=entry_src, keys=PartitionClient.KEY_ENTRY_NAME) entry_copy_name = TestUtils.get_entry_data_by_keys( entry=entry_copy, keys=PartitionClient.KEY_ENTRY_NAME) self.assertEqual( file_name, entry_src_name, 'Expected source file name: ' + str(file_name) + ' but got: ' + str(entry_src_name) + self.extra_data.get_all()) self.assertEqual( file_new_name, entry_copy_name, 'Expected copy file name: ' + str(file_new_name) + ' but got: ' + str(entry_copy_name) + self.extra_data.get_all())