コード例 #1
0
    def test_load_with_archive_filepath_modified(self):
        # Save a visualization for use in the following test case.
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        Visualization._from_data_dir(self.data_dir).save(fp)

        # Load the visualization from a filepath then save a different
        # visualization to the same filepath. Assert that both visualizations
        # access the correct data.
        #
        # `load` used to be lazy, only extracting data when it needed to (e.g.
        # when `save` or `get_index_paths` was called). This was buggy as the
        # filepath could have been deleted, or worse, modified to contain a
        # different .qzv file. Thus, the wrong archive could be extracted on
        # demand, or the archive could be missing altogether. There isn't an
        # easy cross-platform compatible way to solve this problem, so
        # Visualization.load is no longer lazy and always extracts its data
        # immediately. The real motivation for lazy loading was for quick
        # inspection of archives without extracting/copying data, so that API
        # is now provided through Visualization.peek.
        visualization1 = Visualization.load(fp)

        new_data_dir = os.path.join(self.test_dir.name, 'viz-output2')
        os.mkdir(new_data_dir)
        most_common_viz(new_data_dir, collections.Counter(range(42)))

        Visualization._from_data_dir(new_data_dir).save(fp)
        visualization2 = Visualization.load(fp)

        self.assertEqual(visualization1.get_index_paths(),
                         {'html': 'data/index.html'})
        self.assertEqual(visualization2.get_index_paths(), {
            'html': 'data/index.html',
            'tsv': 'data/index.tsv'
        })
コード例 #2
0
ファイル: test_visualization.py プロジェクト: nightest/qiime2
    def test_ne_same_data_different_uuid(self):
        visualization1 = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())
        visualization2 = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())

        self.assertNotEqual(visualization1, visualization2)
コード例 #3
0
    def test_load_with_archive_filepath_modified(self):
        # Save a visualization for use in the following test case.
        fp = os.path.join(self.test_dir.name, 'visualization.qza')
        Visualization._from_data_dir(self.data_dir, None).save(fp)

        # Load the visualization from a filepath then save a different
        # visualization to the same filepath. Assert that both visualizations
        # access the correct data.
        #
        # `load` used to be lazy, only extracting data when it needed to (e.g.
        # when `save` or `get_index_paths` was called). This was buggy as the
        # filepath could have been deleted, or worse, modified to contain a
        # different .qzv file. Thus, the wrong archive could be extracted on
        # demand, or the archive could be missing altogether. There isn't an
        # easy cross-platform compatible way to solve this problem, so
        # Visualization.load is no longer lazy and always extracts its data
        # immediately. The real motivation for lazy loading was for quick
        # inspection of archives without extracting/copying data, so that API
        # is now provided through Visualization.peek.
        visualization1 = Visualization.load(fp)

        new_data_dir = os.path.join(self.test_dir.name, 'viz-output2')
        os.mkdir(new_data_dir)
        most_common_viz(new_data_dir, collections.Counter(range(42)))

        Visualization._from_data_dir(new_data_dir, None).save(fp)
        visualization2 = Visualization.load(fp)

        self.assertEqual(visualization1.get_index_paths(),
                         {'html': 'data/index.html'})
        self.assertEqual(visualization2.get_index_paths(),
                         {'html': 'data/index.html', 'tsv': 'data/index.tsv'})
コード例 #4
0
    def test_ne_different_data_different_uuid(self):
        visualization1 = Visualization._from_data_dir(self.data_dir)

        data_dir = os.path.join(self.test_dir.name, 'mc-viz-output1')
        os.mkdir(data_dir)
        most_common_viz(data_dir, collections.Counter(range(42)))
        visualization2 = Visualization._from_data_dir(data_dir)

        self.assertNotEqual(visualization1, visualization2)
コード例 #5
0
ファイル: test_visualization.py プロジェクト: qiime2/qiime2
    def test_ne_different_data_different_uuid(self):
        visualization1 = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())

        data_dir = os.path.join(self.test_dir.name, 'mc-viz-output1')
        os.mkdir(data_dir)
        most_common_viz(data_dir,
                        collections.Counter(range(42)))
        visualization2 = Visualization._from_data_dir(
            data_dir, self.make_provenance_capture())

        self.assertNotEqual(visualization1, visualization2)
コード例 #6
0
    def test_get_index_paths_single_from_data_dir(self):
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html'}
        self.assertEqual(actual, expected)
コード例 #7
0
    def test_from_data_dir_with_provenance(self):
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)

        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertEqual(visualization.provenance, self.provenance)
        self.assertIsInstance(visualization.uuid, uuid.UUID)
コード例 #8
0
ファイル: test_visualization.py プロジェクト: nightest/qiime2
    def test_get_index_paths_single_from_data_dir(self):
        visualization = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html'}
        self.assertEqual(actual, expected)
コード例 #9
0
    def test_load_and_save(self):
        fp1 = os.path.join(self.test_dir.name, 'visualization1.qzv')
        fp2 = os.path.join(self.test_dir.name, 'visualization2.qzv')
        visualization = Visualization._from_data_dir(self.data_dir)
        visualization.save(fp1)

        visualization = Visualization.load(fp1)
        # Overwriting its source file works.
        visualization.save(fp1)
        # Saving to a new file works.
        visualization.save(fp2)

        root_dir = str(visualization.uuid)
        expected = {
            'VERSION', 'metadata.yaml', 'data/index.html', 'data/css/style.css'
        }

        self.assertArchiveMembers(fp1, root_dir, expected)

        root_dir = str(visualization.uuid)
        expected = {
            'VERSION', 'metadata.yaml', 'data/index.html', 'data/css/style.css'
        }

        self.assertArchiveMembers(fp2, root_dir, expected)
コード例 #10
0
    def test_load_and_save(self):
        fp1 = os.path.join(self.test_dir.name, 'visualization1.qzv')
        fp2 = os.path.join(self.test_dir.name, 'visualization2.qzv')
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)
        visualization.save(fp1)

        visualization = Visualization.load(fp1)
        # Overwriting its source file works.
        visualization.save(fp1)
        # Saving to a new file works.
        visualization.save(fp2)

        with zipfile.ZipFile(fp1, mode='r') as zf:
            fps = set(zf.namelist())
            expected = {
                'visualization1/VERSION',
                'visualization1/metadata.yaml',
                'visualization1/README.md',
                'visualization1/data/index.html',
                'visualization1/data/css/style.css'
            }
            self.assertEqual(fps, expected)

        with zipfile.ZipFile(fp2, mode='r') as zf:
            fps = set(zf.namelist())
            expected = {
                'visualization2/VERSION',
                'visualization2/metadata.yaml',
                'visualization2/README.md',
                'visualization2/data/index.html',
                'visualization2/data/css/style.css'
            }
            self.assertEqual(fps, expected)
コード例 #11
0
    def test_from_data_dir(self):
        visualization = Visualization._from_data_dir(self.data_dir, None)

        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertIsNone(visualization.provenance)
        # We don't know what the UUID is because it's generated within
        # Visualization._from_data_dir.
        self.assertIsInstance(visualization.uuid, uuid.UUID)
コード例 #12
0
    def test_eq_same_uuid(self):
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization1 = Visualization._from_data_dir(self.data_dir)
        visualization1.save(fp)

        visualization2 = Visualization.load(fp)

        self.assertEqual(visualization1, visualization2)
コード例 #13
0
ファイル: test_result.py プロジェクト: BenKaehler/qiime2
    def test_load_visualization_as_artifact(self):
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)
        visualization.save(fp)

        with self.assertRaisesRegex(
                TypeError, 'Visualization.*Artifact.load.*Visualization.load'):
            Artifact.load(fp)
コード例 #14
0
ファイル: test_result.py プロジェクト: BenKaehler/qiime2
    def test_extract_visualization_as_artifact(self):
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)
        visualization.save(fp)

        with self.assertRaisesRegex(
                TypeError, 'Artifact does not support.*Visualization'):
            Artifact.extract(fp, self.test_dir)
コード例 #15
0
    def test_get_index_paths_multiple_html_from_data_dir(self):
        data_dir = os.path.join(self.test_dir.name, 'multi-html-viz2')
        os.mkdir(data_dir)
        multi_html_viz(data_dir, [1, 42])

        visualization = Visualization._from_data_dir(data_dir)

        with self.assertRaises(ValueError):
            visualization.get_index_paths()
コード例 #16
0
    def test_get_index_paths_multiple_from_data_dir(self):
        data_dir = os.path.join(self.test_dir.name, 'mc-viz-output2')
        os.mkdir(data_dir)
        most_common_viz(data_dir, collections.Counter(range(42)))
        visualization = Visualization._from_data_dir(data_dir)

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html', 'tsv': 'data/index.tsv'}
        self.assertEqual(actual, expected)
コード例 #17
0
    def test_get_index_paths_single_load(self):
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization = Visualization._from_data_dir(self.data_dir)
        visualization.save(fp)
        visualization = Visualization.load(fp)

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html'}
        self.assertEqual(actual, expected)
コード例 #18
0
    def test_load(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 = Visualization.load(fp)

        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertEqual(visualization.uuid, saved_visualization.uuid)
コード例 #19
0
ファイル: test_visualization.py プロジェクト: qiime2/qiime2
    def test_eq_same_uuid(self):
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization1 = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())
        visualization1.save(fp)

        visualization2 = Visualization.load(fp)

        self.assertEqual(visualization1, visualization2)
コード例 #20
0
    def test_get_index_paths_multiple_html_from_data_dir(self):
        data_dir = os.path.join(self.test_dir.name, 'multi-html-viz2')
        os.mkdir(data_dir)
        multi_html_viz(data_dir, [1, 42])

        visualization = Visualization._from_data_dir(data_dir,
                                                     self.provenance)

        with self.assertRaises(ValueError):
            visualization.get_index_paths()
コード例 #21
0
    def test_load(self):
        saved_visualization = Visualization._from_data_dir(self.data_dir, None)
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        saved_visualization.save(fp)

        visualization = Visualization.load(fp)

        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertIsNone(visualization.provenance)
        self.assertEqual(visualization.uuid, saved_visualization.uuid)
コード例 #22
0
    def test_get_index_paths_single_load(self):
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)
        visualization.save(fp)
        visualization = Visualization.load(fp)

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html'}
        self.assertEqual(actual, expected)
コード例 #23
0
    def test_ne_different_type_same_uuid(self):
        visualization = Visualization._from_data_dir(self.data_dir)

        class Faker:
            @property
            def uuid(self):
                return visualization.uuid

        faker = Faker()

        self.assertNotEqual(visualization, faker)
コード例 #24
0
ファイル: test_result.py プロジェクト: nightest/qiime2
    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)
コード例 #25
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)
コード例 #26
0
    def test_save_visualization_warning(self):
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)
        fp = os.path.join(self.test_dir.name, 'visualization.zip')

        with warnings.catch_warnings(record=True) as w:
            visualization.save(fp)

            self.assertEqual(len(w), 1)
            self.assertIsInstance(w[0].message, UserWarning)
            self.assertIn(Visualization.extension, str(w[0].message))
コード例 #27
0
    def test_peek(self):
        visualization = Visualization._from_data_dir(self.data_dir, None)
        fp = os.path.join(self.test_dir.name, 'visualization.qza')
        visualization.save(fp)

        metadata = Visualization.peek(fp)

        self.assertIsInstance(metadata, ResultMetadata)
        self.assertEqual(metadata.type, qiime.core.type.Visualization)
        self.assertIsNone(metadata.provenance)
        self.assertEqual(metadata.uuid, visualization.uuid)
コード例 #28
0
    def test_get_index_paths_multiple_from_data_dir(self):
        data_dir = os.path.join(self.test_dir.name, 'mc-viz-output2')
        os.mkdir(data_dir)
        most_common_viz(data_dir, collections.Counter(range(42)))
        visualization = Visualization._from_data_dir(data_dir,
                                                     self.provenance)

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html',
                    'tsv': 'data/index.tsv'}
        self.assertEqual(actual, expected)
コード例 #29
0
ファイル: test_result.py プロジェクト: qiime2/qiime2
    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)
コード例 #30
0
    def test_from_data_dir_and_save(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)
        expected = {
            'VERSION', 'metadata.yaml', 'data/index.html', 'data/css/style.css'
        }

        self.assertArchiveMembers(fp, root_dir, expected)
コード例 #31
0
ファイル: test_visualization.py プロジェクト: qiime2/qiime2
    def test_ne_different_type_same_uuid(self):
        visualization = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())

        class Faker:
            @property
            def uuid(self):
                return visualization.uuid

        faker = Faker()

        self.assertNotEqual(visualization, faker)
コード例 #32
0
    def test_roundtrip(self):
        fp1 = os.path.join(self.test_dir.name, 'visualization1.qzv')
        fp2 = os.path.join(self.test_dir.name, 'visualization2.qzv')
        visualization = Visualization._from_data_dir(self.data_dir)
        visualization.save(fp1)

        visualization1 = Visualization.load(fp1)
        visualization1.save(fp2)
        visualization2 = Visualization.load(fp2)

        self.assertEqual(visualization1.type, visualization2.type)
        self.assertEqual(visualization1.uuid, visualization2.uuid)
コード例 #33
0
ファイル: test_result.py プロジェクト: BenKaehler/qiime2
    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)
コード例 #34
0
    def test_get_index_paths_relative_false(self):
        data_dir = os.path.join(self.test_dir.name, 'mc-viz-output2')
        os.mkdir(data_dir)
        most_common_viz(data_dir, collections.Counter(range(42)))
        visualization = Visualization._from_data_dir(data_dir,
                                                     self.provenance)

        def get_abs_path(rel):
            return os.path.join(visualization._archiver._temp_dir, rel)
        actual = visualization.get_index_paths(relative=False)
        expected = {'html': get_abs_path('data/index.html'),
                    'tsv': get_abs_path('data/index.tsv')}
        self.assertEqual(actual, expected)
コード例 #35
0
ファイル: test_visualization.py プロジェクト: qiime2/qiime2
    def test_roundtrip(self):
        fp1 = os.path.join(self.test_dir.name, 'visualization1.qzv')
        fp2 = os.path.join(self.test_dir.name, 'visualization2.qzv')
        visualization = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())
        visualization.save(fp1)

        visualization1 = Visualization.load(fp1)
        visualization1.save(fp2)
        visualization2 = Visualization.load(fp2)

        self.assertEqual(visualization1.type, visualization2.type)
        self.assertEqual(visualization1.uuid, visualization2.uuid)
コード例 #36
0
ファイル: test_visualization.py プロジェクト: nightest/qiime2
    def test_get_index_paths_multiple_html_load(self):
        data_dir = os.path.join(self.test_dir.name, 'multi-html-viz1')
        os.mkdir(data_dir)
        multi_html_viz(data_dir, [1, 42])

        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization = Visualization._from_data_dir(
            data_dir, self.make_provenance_capture())
        visualization.save(fp)
        visualization = Visualization.load(fp)

        with self.assertRaises(ValueError):
            visualization.get_index_paths()
コード例 #37
0
ファイル: test_visualization.py プロジェクト: nightest/qiime2
    def test_get_index_paths_relative_false(self):
        data_dir = os.path.join(self.test_dir.name, 'mc-viz-output2')
        os.mkdir(data_dir)
        most_common_viz(data_dir, collections.Counter(range(42)))
        visualization = Visualization._from_data_dir(
            data_dir, self.make_provenance_capture())

        def get_abs_path(rel):
            return str(visualization._archiver.root_dir / rel)
        actual = visualization.get_index_paths(relative=False)
        expected = {'html': get_abs_path('data/index.html'),
                    'tsv': get_abs_path('data/index.tsv')}
        self.assertEqual(actual, expected)
コード例 #38
0
ファイル: test_visualization.py プロジェクト: nightest/qiime2
    def test_get_index_paths_multiple_load(self):
        data_dir = os.path.join(self.test_dir.name, 'mc-viz-output1')
        os.mkdir(data_dir)
        most_common_viz(data_dir,
                        collections.Counter(range(42)))
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization = Visualization._from_data_dir(
            data_dir, self.make_provenance_capture())
        visualization.save(fp)
        visualization = Visualization.load(fp)

        actual = visualization.get_index_paths()
        expected = {'html': 'data/index.html',
                    'tsv': 'data/index.tsv'}
        self.assertEqual(actual, expected)
コード例 #39
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)
コード例 #40
0
    def test_from_data_dir_and_save(self):
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        visualization = Visualization._from_data_dir(self.data_dir,
                                                     self.provenance)

        visualization.save(fp)

        with zipfile.ZipFile(fp, mode='r') as zf:
            fps = set(zf.namelist())
            expected = {
                'visualization/VERSION',
                'visualization/metadata.yaml',
                'visualization/README.md',
                'visualization/data/index.html',
                'visualization/data/css/style.css'
            }
            self.assertEqual(fps, expected)
コード例 #41
0
ファイル: test_visualization.py プロジェクト: qiime2/qiime2
    def test_from_data_dir_and_save(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)
        expected = {
            'VERSION',
            'metadata.yaml',
            'data/index.html',
            'data/css/style.css',
            'provenance/metadata.yaml',
            'provenance/VERSION',
            'provenance/action/action.yaml'
        }

        self.assertArchiveMembers(fp, root_dir, expected)
コード例 #42
0
ファイル: test_result.py プロジェクト: BenKaehler/qiime2
    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)
コード例 #43
0
    def test_extract(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 = Visualization.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)
コード例 #44
0
ファイル: test_result.py プロジェクト: qiime2/qiime2
    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)
コード例 #45
0
ファイル: test_visualization.py プロジェクト: qiime2/qiime2
    def test_load_and_save(self):
        fp1 = os.path.join(self.test_dir.name, 'visualization1.qzv')
        fp2 = os.path.join(self.test_dir.name, 'visualization2.qzv')
        visualization = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())
        visualization.save(fp1)

        visualization = Visualization.load(fp1)
        # Overwriting its source file works.
        visualization.save(fp1)
        # Saving to a new file works.
        visualization.save(fp2)

        root_dir = str(visualization.uuid)
        expected = {
            'VERSION',
            'metadata.yaml',
            'data/index.html',
            'data/css/style.css',
            'provenance/metadata.yaml',
            'provenance/VERSION',
            'provenance/action/action.yaml'
        }

        self.assertArchiveMembers(fp1, root_dir, expected)

        root_dir = str(visualization.uuid)
        expected = {
            'VERSION',
            'metadata.yaml',
            'data/index.html',
            'data/css/style.css',
            'provenance/metadata.yaml',
            'provenance/VERSION',
            'provenance/action/action.yaml'
        }

        self.assertArchiveMembers(fp2, root_dir, expected)
コード例 #46
0
    def test_save_visualization_auto_extension(self):
        visualization = Visualization._from_data_dir(self.data_dir)

        # No extension.
        fp = os.path.join(self.test_dir.name, 'visualization')
        obs_fp = visualization.save(fp)
        obs_filename = os.path.basename(obs_fp)

        self.assertEqual(obs_filename, 'visualization.qzv')

        # Wrong extension.
        fp = os.path.join(self.test_dir.name, 'visualization.zip')
        obs_fp = visualization.save(fp)
        obs_filename = os.path.basename(obs_fp)

        self.assertEqual(obs_filename, 'visualization.zip.qzv')

        # Correct extension.
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        obs_fp = visualization.save(fp)
        obs_filename = os.path.basename(obs_fp)

        self.assertEqual(obs_filename, 'visualization.qzv')
コード例 #47
0
ファイル: test_result.py プロジェクト: qiime2/qiime2
    def test_save_visualization_auto_extension(self):
        visualization = Visualization._from_data_dir(
             self.data_dir, self.make_provenance_capture())

        # No extension.
        fp = os.path.join(self.test_dir.name, 'visualization')
        obs_fp = visualization.save(fp)
        obs_filename = os.path.basename(obs_fp)

        self.assertEqual(obs_filename, 'visualization.qzv')

        # Wrong extension.
        fp = os.path.join(self.test_dir.name, 'visualization.zip')
        obs_fp = visualization.save(fp)
        obs_filename = os.path.basename(obs_fp)

        self.assertEqual(obs_filename, 'visualization.zip.qzv')

        # Correct extension.
        fp = os.path.join(self.test_dir.name, 'visualization.qzv')
        obs_fp = visualization.save(fp)
        obs_filename = os.path.basename(obs_fp)

        self.assertEqual(obs_filename, 'visualization.qzv')
コード例 #48
0
    def test_ne_same_data_different_uuid(self):
        visualization1 = Visualization._from_data_dir(self.data_dir)
        visualization2 = Visualization._from_data_dir(self.data_dir)

        self.assertNotEqual(visualization1, visualization2)
コード例 #49
0
    def test_eq_identity(self):
        visualization = Visualization._from_data_dir(self.data_dir)

        self.assertEqual(visualization, visualization)
コード例 #50
0
ファイル: test_visualization.py プロジェクト: nightest/qiime2
    def test_from_data_dir(self):
        visualization = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())

        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertIsInstance(visualization.uuid, uuid.UUID)
コード例 #51
0
    def test_from_data_dir(self):
        visualization = Visualization._from_data_dir(self.data_dir)

        self.assertEqual(visualization.type, qiime.core.type.Visualization)
        self.assertIsInstance(visualization.uuid, uuid.UUID)
コード例 #52
0
ファイル: test_visualization.py プロジェクト: nightest/qiime2
    def test_eq_identity(self):
        visualization = Visualization._from_data_dir(
            self.data_dir, self.make_provenance_capture())

        self.assertEqual(visualization, visualization)