Skip to content
Snippets Groups Projects
Commit 5a54dae7 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: split unittests in TableImporter and XLSImporter

parent de569ba6
No related branches found
No related tags found
1 merge request!22Release 0.3
......@@ -30,6 +30,9 @@ from caosadvancedtools.datainconsistency import DataInconsistencyError
from caosadvancedtools.table_importer import (XLSImporter, assure_name_format,
date_converter,
datetime_converter,
TableImporter,
TSVImporter,
CSVImporter,
incomplete_date_converter,
win_path_converter,
win_path_list_converter,
......@@ -125,9 +128,9 @@ class ConverterTest(unittest.TestCase):
fmts={"%Y": "%Y"})
class XLSImporterTest(unittest.TestCase):
class TableImporterTest(unittest.TestCase):
def setUp(self):
self.importer = XLSImporter(
self.importer = TableImporter(
converters={'a': str, 'b': int, 'c': float, 'd': yes_no_converter},
obligatory_columns=['a', 'b'], unique_keys=[('a', 'b')])
self.valid_df = pd.DataFrame(
......@@ -150,13 +153,6 @@ class XLSImporterTest(unittest.TestCase):
self.assertEqual(df_new.shape[1], 4)
self.assertEqual(df_new.iloc[0].b, 5)
def test_full(self):
""" test full run with example data """
tmp = NamedTemporaryFile(delete=False, suffix=".xlsx")
tmp.close()
self.valid_df.to_excel(tmp.name)
self.importer.read_xls(tmp.name)
def test_unique(self):
self.importer.check_missing(self.valid_df)
df = pd.DataFrame([['b', 5, 3.0, 'no'], ['b', 5, 3.0, 'no']],
......@@ -164,6 +160,15 @@ class XLSImporterTest(unittest.TestCase):
df_new = self.importer.check_unique(df)
self.assertEqual(df_new.shape[0], 1)
class XLSImporterTest(TableImporterTest):
def test_full(self):
""" test full run with example data """
tmp = NamedTemporaryFile(delete=False, suffix=".xlsx")
tmp.close()
self.valid_df.to_excel(tmp.name)
self.importer.read_xls(tmp.name)
def test_raise(self):
tmp = NamedTemporaryFile(delete=False, suffix=".lol")
tmp.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment