-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring tests to separate util testing from actual methods
- Loading branch information
Showing
3 changed files
with
52 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# ---------------------------------------------------------------------------- | ||
# Copyright (c) 2023-2024, QIIME 2 development team. | ||
# | ||
# Distributed under the terms of the Modified BSD License. | ||
# | ||
# The full license is in the file LICENSE, distributed with this software. | ||
# ---------------------------------------------------------------------------- | ||
|
||
import pandas as pd | ||
|
||
from qiime2.plugin.testing import TestPluginBase | ||
from qiime2 import Metadata | ||
|
||
from .._util import _measure_validation | ||
|
||
|
||
class TestBase(TestPluginBase): | ||
package = 'q2_vizard.tests' | ||
|
||
def setUp(self): | ||
super().setUp() | ||
index = pd.Index(['sample1', 'sample2', 'sample3'], | ||
name='sample-id') | ||
data = [ | ||
[1.0, 'foo'], | ||
[2.0, 'bar'], | ||
[3.0, 'baz'] | ||
] | ||
self.md = Metadata(pd.DataFrame(data=data, index=index, dtype=object, | ||
columns=['numeric-col', | ||
'categorical-col'])) | ||
|
||
|
||
class TestMeasureValidation(TestBase): | ||
def test_measure_not_in_metadata(self): | ||
with self.assertRaisesRegex(ValueError, '`boo` not found as a column'): | ||
_measure_validation(metadata=self.md, measure='boo', | ||
col_type='numeric') | ||
|
||
def test_measure_not_categorical(self): | ||
with self.assertRaisesRegex( | ||
TypeError, '`categorical-col` not.*`NumericMetadataColumn`' | ||
): | ||
_measure_validation(metadata=self.md, measure='categorical-col', | ||
col_type='numeric') | ||
|
||
def test_measure_not_numeric(self): | ||
with self.assertRaisesRegex( | ||
TypeError, '`numeric-col` not.*`CategoricalMetadataColumn`' | ||
): | ||
_measure_validation(metadata=self.md, measure='numeric-col', | ||
col_type='categorical') |