Esempio n. 1
0
    def test_load_visualization(self):
        saved_visualization = Visualization._from_data_dir(self.data_dir)
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        saved_visualization.save(fp)

        visualization = Result.load(fp)

        self.assertIsInstance(visualization, Visualization)
        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertEqual(visualization.uuid, saved_visualization.uuid)
Esempio n. 2
0
    def test_load_visualization(self):
        saved_visualization = Visualization._from_data_dir(
             self.data_dir, self.make_provenance_capture())
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        saved_visualization.save(fp)

        visualization = Result.load(fp)

        self.assertIsInstance(visualization, Visualization)
        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertEqual(visualization.uuid, saved_visualization.uuid)
Esempio n. 3
0
    def test_load_artifact(self):
        saved_artifact = Artifact.import_data(FourInts, [-1, 42, 0, 43])
        fp = os.path.join(self.test_dir.name, 'artifact.qza')
        saved_artifact.save(fp)

        artifact = Result.load(fp)

        self.assertIsInstance(artifact, Artifact)
        self.assertEqual(artifact.type, FourInts)
        self.assertEqual(artifact.uuid, saved_artifact.uuid)
        self.assertEqual(artifact.view(list), [-1, 42, 0, 43])
Esempio n. 4
0
    def test_peek_artifact(self):
        artifact = Artifact.import_data(FourInts, [0, 0, 42, 1000])
        fp = os.path.join(self.test_dir.name, 'artifact.qza')
        artifact.save(fp)

        metadata = Result.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, 'FourInts')
        self.assertEqual(metadata.uuid, str(artifact.uuid))
        self.assertEqual(metadata.format, 'FourIntsDirectoryFormat')
Esempio n. 5
0
    def test_peek_visualization(self):
        visualization = Visualization._from_data_dir(self.data_dir)
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization.save(fp)

        metadata = Result.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, 'Visualization')
        self.assertEqual(metadata.uuid, str(visualization.uuid))
        self.assertIsNone(metadata.format)
Esempio n. 6
0
    def test_peek_visualization(self):
        visualization = Visualization._from_data_dir(
             self.data_dir, self.make_provenance_capture())
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization.save(fp)

        metadata = Result.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, 'Visualization')
        self.assertEqual(metadata.uuid, str(visualization.uuid))
        self.assertIsNone(metadata.format)
Esempio n. 7
0
    def test_peek_visualization(self):
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization.save(fp)

        metadata = Result.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, qiime.core.type.Visualization)
        self.assertEqual(metadata.provenance, self.provenance)
        self.assertEqual(metadata.uuid, visualization.uuid)
Esempio n. 8
0
    def test_peek_artifact(self):
        artifact = Artifact._from_view(FourInts, [0, 0, 42, 1000], list,
                                       self.provenance)
        fp = os.path.join(self.test_dir.name, 'artifact.qza')
        artifact.save(fp)

        metadata = Result.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, FourInts)
        self.assertEqual(metadata.provenance, self.provenance)
        self.assertEqual(metadata.uuid, artifact.uuid)
Esempio n. 9
0
    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)
Esempio n. 10
0
    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)
Esempio n. 11
0
    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)
Esempio n. 12
0
    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)
Esempio n. 13
0
    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)
Esempio n. 14
0
    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)
Esempio n. 15
0
 def test_private_constructor(self):
     with self.assertRaisesRegex(
             NotImplementedError,
             'Result constructor.*private.*Result.load'):
         Result()