def test_freeze_file(self): data = { "project": "Project_A", "pathname": "/2017-10/Experiment_3/test01.dat" } user = '******' status, res = ida.freeze_file(user, data) self.assertIn(status, self.OK, 'freeze fails') file_is_in_metax = ida.wait_until_file_appears_in_metax( data['project'], data['pathname']) self.assertEqual(file_is_in_metax, True, 'Frozen file never appeared in metax')
def _freeze_directory_in_ida(cls): """ Freeze an existing test directory in IDA staging area, so the file metadata ends up in Metax. """ data = { "project": cls._test_project_identifier, "pathname": cls._test_directory_path } status, res = ida.freeze_file(cls._test_project_user, data) assert status in cls.OK, 'test setup failed: ida freeze file returned %s' % status file_is_in_metax = ida.wait_until_file_appears_in_metax( data['project'], data['pathname']) assert file_is_in_metax is True, 'test setup failed: frozen file never appeared in metax'
def _freeze_files(self): data = {"project": pas.project, "pathname": "/files"} status, response = ida.freeze_file(pas.project_user, data) self.assertIn(status, self.OK, 'freeze fails: ' + str(response)) self.files_freezed_in_ida = True file_is_in_metax = pas.wait_until_directory_appears_in_metax( data['project'], data['pathname']) self.assertEqual(file_is_in_metax, True, 'Frozen file never appeared in metax') status, response = ida.get_frozen_node_action(pas.project_user, response['pid']) self.assertIn(status, self.OK, 'Reading file details from IDA fails: ' + str(response)) return response
def test_delete_file(self): data = { "project": "Project_A", "pathname": "/2017-10/Experiment_4/test03.dat" } user = '******' # set test conditions... status, res = ida.freeze_file(user, data) self.assertIn(status, self.OK, 'freeze fails') file_is_in_metax = ida.wait_until_file_appears_in_metax( data['project'], data['pathname']) self.assertEqual(file_is_in_metax, True, 'Frozen file never appeared in metax') # the actual test data = { "nextcloudNodeId": res['node'], "project": "Project_A", "pathname": "/2017-10/Experiment_4/test03.dat" } for i in range(0, 60): status = ida.delete_file(user, data) if status == 200: print('delete success') break # it may take a moment for the previous freeze action to complete. if the # previous action is not completed, a delete action too soon will cause # a conflicting-action error. time.sleep(1) if i % 5 == 0 and i > 0: print( 'delete probably still conflicting with freeze action, waiting a bit...' ) self.assertIn(status, self.OK, 'Ida file delete failed') file_disappeared_from_metax = ida.wait_until_file_disappears_from_metax( data['project'], data['pathname']) self.assertEqual(file_disappeared_from_metax, True, 'Frozen file never disappeared from metax')