def test_import_old_local_archives(self): """ Test import of old local archives Expected behavior: Automatically migrate to newest version and import correctly. """ archives = [] for version in range(1, int(EXPORT_VERSION.split('.')[-1]) - 1): archives.append(('export_v0.{}_simple.aiida'.format(version), '0.{}'.format(version))) for archive, version in archives: options = [get_archive_file(archive, filepath=self.archive_path)] result = self.cli_runner.invoke(cmd_import.cmd_import, options) self.assertIsNone(result.exception, msg=result.output) self.assertEqual(result.exit_code, 0, msg=result.output) self.assertIn(version, result.output, msg=result.exception) self.assertIn('Success: imported archive {}'.format(options[0]), result.output, msg=result.exception)
def test_migrate_versions_old(self): """Migrating archives with a version older than the current should work.""" archives = [] for version in range(1, int(EXPORT_VERSION.split('.')[-1]) - 1): archives.append('export_v0.{}_simple.aiida'.format(version)) for archive in archives: filename_input = get_archive_file(archive, filepath=self.fixture_archive) filename_output = next(tempfile._get_candidate_names()) # pylint: disable=protected-access try: options = [filename_input, filename_output] result = self.cli_runner.invoke(cmd_export.migrate, options) self.assertIsNone(result.exception, result.output) self.assertTrue(os.path.isfile(filename_output)) self.assertEqual( zipfile.ZipFile(filename_output).testzip(), None) finally: delete_temporary_file(filename_output)
def test_inspect(self): """Test the functionality of `verdi export inspect`.""" archives = [] for version in range(1, int(EXPORT_VERSION.split('.')[-1])): archives.append(('export_v0.{}_simple.aiida'.format(version), '0.{}'.format(version))) for archive, version_number in archives: filename_input = get_archive_file(archive, filepath=self.fixture_archive) # Testing the options that will print the meta data and data respectively for option in ['-m', '-d']: options = [option, filename_input] result = self.cli_runner.invoke(cmd_export.inspect, options) self.assertIsNone(result.exception, result.output) # Test the --version option which should print the archive format version options = ['--version', filename_input] result = self.cli_runner.invoke(cmd_export.inspect, options) self.assertIsNone(result.exception, result.output) self.assertEqual(result.output.strip(), version_number)