Skip to content

Speedup metadata tests #1033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 2, 2015
Merged
4 changes: 1 addition & 3 deletions qiita_db/metadata_template/base_metadata_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ class MetadataTemplate(QiitaObject):

Methods
-------
create
exists
__len__
__getitem__
Expand Down Expand Up @@ -533,6 +532,7 @@ def delete(cls, id_):
QiitaDBUnknownIDError
If no metadata_template with id id_ exists
"""
cls._check_subclass()
if not cls.exists(id_):
raise QiitaDBUnknownIDError(id_, cls.__name__)

Expand Down Expand Up @@ -825,8 +825,6 @@ def to_dataframe(self):
pandas DataFrame
The metadata in the template,indexed on sample id
"""
# Check that we are not instantiating the base class
self._check_subclass()
conn_handler = SQLConnectionHandler()
cols = get_table_cols(self._table, conn_handler)
if 'study_id' in cols:
Expand Down
22 changes: 8 additions & 14 deletions qiita_db/metadata_template/test/test_base_metadata_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@

from qiita_core.util import qiita_test_checker
from qiita_core.exceptions import IncompetentQiitaDeveloperError
from qiita_db.exceptions import QiitaDBNotImplementedError
from qiita_db.study import Study
from qiita_db.metadata_template.base_metadata_template import (
MetadataTemplate, BaseSample)
from qiita_db.metadata_template.sample_template import SampleTemplate


@qiita_test_checker()
class TestBaseSample(TestCase):
"""Tests the BaseSample class"""

Expand All @@ -32,8 +30,7 @@ def test_exists(self):
BaseSample.exists('SKM7.640188', SampleTemplate(1))


@qiita_test_checker()
class TestMetadataTemplate(TestCase):
class TestMetadataTemplateReadOnly(TestCase):
"""Tests the MetadataTemplate base class"""
def setUp(self):
self.study = Study(1)
Expand All @@ -43,11 +40,6 @@ def test_init(self):
with self.assertRaises(IncompetentQiitaDeveloperError):
MetadataTemplate(1)

def test_create(self):
"""Create raises an error because it's not called from a subclass"""
with self.assertRaises(QiitaDBNotImplementedError):
MetadataTemplate.create()

def test_exist(self):
"""Exists raises an error because it's not called from a subclass"""
with self.assertRaises(IncompetentQiitaDeveloperError):
Expand All @@ -59,11 +51,13 @@ def test_table_name(self):
with self.assertRaises(IncompetentQiitaDeveloperError):
MetadataTemplate._table_name(self.study)

def test_to_dataframe(self):
"""to dataframeraises an error because it's not called from a subclass
"""
with self.assertRaises(TypeError):
MetadataTemplate.to_dataframe()

@qiita_test_checker()
class TestMetadataTemplateReadWrite(TestCase):
def test_delete(self):
"""delete raises an error because it's not called from a subclass"""
with self.assertRaises(IncompetentQiitaDeveloperError):
MetadataTemplate.delete(1)

if __name__ == '__main__':
main()
Loading