Add test for tabular pipeline

This commit is contained in:
davidmezzetti
2021-12-14 15:10:13 -05:00
parent f84ed38c1b
commit 4fa2d2da45
2 changed files with 29 additions and 2 deletions
+27
View File
@@ -23,6 +23,33 @@ class TestTabular(unittest.TestCase):
cls.tabular = Tabular("id", ["text"])
def testContent(self):
"""
Tests parsing additional content
"""
tabular = Tabular("id", ["text"], True)
row = {"id": 0, "text": "This is a test", "flag": 1}
# When content is enabled, both (uid, text, tags) and (uid, data, tags) rows will be generated
rows = tabular([row])
uid, data, _ = rows[1]
# Data should contain the entire input row
self.assertEqual(uid, 0)
self.assertEqual(data, row)
# Only select flag field
tabular.content = ["flag"]
rows = tabular([row])
uid, data, _ = rows[1]
# Data should only contain a single field, flag
self.assertEqual(uid, 0)
self.assertTrue(list(data.keys()) == ["flag"])
self.assertEqual(data["flag"], 1)
def testCSV(self):
"""
Tests parsing a CSV file