def test_extract_visualization(self): fp = os.path.join(self.test_dir.name, 'visualization.qzv') visualization = Visualization._from_data_dir(self.data_dir) visualization.save(fp) root_dir = str(visualization.uuid) output_dir = os.path.join(self.test_dir.name, 'viz-extract-test') result_dir = Result.extract(fp, output_dir=output_dir) self.assertEqual(result_dir, os.path.join(output_dir, root_dir)) expected = { 'VERSION', 'metadata.yaml', 'data/index.html', 'data/css/style.css' } self.assertExtractedArchiveMembers(output_dir, root_dir, expected)
def test_extract_artifact(self): fp = os.path.join(self.test_dir.name, 'artifact.qza') artifact = Artifact._from_view(FourInts, [-1, 42, 0, 43], list) artifact.save(fp) root_dir = str(artifact.uuid) output_dir = os.path.join(self.test_dir.name, 'artifact-extract-test') result_dir = Result.extract(fp, output_dir=output_dir) self.assertEqual(result_dir, os.path.join(output_dir, root_dir)) expected = { 'VERSION', 'metadata.yaml', 'data/file1.txt', 'data/file2.txt', 'data/nested/file3.txt', 'data/nested/file4.txt' } self.assertExtractedArchiveMembers(output_dir, root_dir, expected)
def test_extract_visualization(self): fp = os.path.join(self.test_dir.name, 'visualization.qzv') visualization = Visualization._from_data_dir(self.data_dir, self.provenance) visualization.save(fp) output_dir = os.path.join(self.test_dir.name, 'viz-extract-test') result_dir = Result.extract(fp, output_dir=output_dir) self.assertEqual(result_dir, output_dir) contents = [ 'visualization/VERSION', 'visualization/metadata.yaml', 'visualization/README.md', 'visualization/data/index.html', 'visualization/data/css/style.css' ] for fp in contents: expected_fp = os.path.join(output_dir, fp) self.assertTrue(os.path.exists(expected_fp), 'File %s was not extracted.' % fp)
def test_extract_artifact(self): fp = os.path.join(self.test_dir.name, 'artifact.qza') artifact = Artifact._from_view(FourInts, [-1, 42, 0, 43], list, self.provenance) artifact.save(fp) output_dir = os.path.join(self.test_dir.name, 'artifact-extract-test') result_dir = Result.extract(fp, output_dir=output_dir) self.assertEqual(result_dir, output_dir) contents = [ 'artifact/VERSION', 'artifact/metadata.yaml', 'artifact/README.md', 'artifact/data/file1.txt', 'artifact/data/file2.txt', 'artifact/data/nested/file3.txt', 'artifact/data/nested/file4.txt' ] for fp in contents: expected_fp = os.path.join(output_dir, fp) self.assertTrue(os.path.exists(expected_fp), 'File %s was not extracted.' % fp)
def test_extract_visualization(self): fp = os.path.join(self.test_dir.name, 'visualization.qzv') visualization = Visualization._from_data_dir( self.data_dir, self.make_provenance_capture()) visualization.save(fp) root_dir = str(visualization.uuid) output_dir = os.path.join(self.test_dir.name, 'viz-extract-test') result_dir = Result.extract(fp, output_dir=output_dir) self.assertEqual(result_dir, os.path.join(output_dir, root_dir)) expected = { 'VERSION', 'metadata.yaml', 'data/index.html', 'data/css/style.css', 'provenance/metadata.yaml', 'provenance/VERSION', 'provenance/action/action.yaml' } self.assertExtractedArchiveMembers(output_dir, root_dir, expected)
def test_extract_artifact(self): fp = os.path.join(self.test_dir.name, 'artifact.qza') artifact = Artifact.import_data(FourInts, [-1, 42, 0, 43]) artifact.save(fp) root_dir = str(artifact.uuid) output_dir = os.path.join(self.test_dir.name, 'artifact-extract-test') result_dir = Result.extract(fp, output_dir=output_dir) self.assertEqual(result_dir, os.path.join(output_dir, root_dir)) expected = { 'VERSION', 'metadata.yaml', 'data/file1.txt', 'data/file2.txt', 'data/nested/file3.txt', 'data/nested/file4.txt', 'provenance/metadata.yaml', 'provenance/VERSION', 'provenance/action/action.yaml' } self.assertExtractedArchiveMembers(output_dir, root_dir, expected)