Skip to content

Commit

Permalink
fixes #116 add unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Apr 16, 2019
1 parent fcff17c commit 8a17419
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
def suite(*args, **kw):

import test_simple
test_suite = unittest.TestSuite()
import test_excel
test_list = [
test_simple,
test_excel
]

test_suite = unittest.TestSuite()
for test in test_list:
test_suite.addTest(test.suite())
return test_suite
Expand Down
47 changes: 47 additions & 0 deletions tests/test_excel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

"""
simple unit tests for this package
"""

import os
import sys
import unittest

PATH = os.path.dirname(__file__)
_path = os.path.join(PATH, '..')
if _path not in sys.path:
sys.path.insert(0, _path)

import apstools.utils


class Test_Demo3(unittest.TestCase):

xl_file = os.path.join(PATH, "demo3.xlsx")

def test_ExcelTable_normal_read(self):
xl = apstools.utils.ExcelDatabaseFileGeneric(self.xl_file)
self.assertEqual(len(xl.db), 9) # rows
self.assertEqual(len(xl.db["0"]), 7) # columns
self.assertTrue("Unnamed: 7" in xl.db["0"])
self.assertEqual(xl.db["0"]["Unnamed: 7"], 8.0)

def test_ExcelTable_ignore_extra_false(self):
xl = apstools.utils.ExcelDatabaseFileGeneric(self.xl_file, ignore_extra=False)
self.assertEqual(len(xl.db), 16) # rows
self.assertEqual(len(xl.db["0"]), 9) # columns


def suite(*args, **kw):
test_list = [
Test_Demo3,
]
test_suite = unittest.TestSuite()
for test_case in test_list:
test_suite.addTest(unittest.makeSuite(test_case))
return test_suite


if __name__ == "__main__":
runner=unittest.TextTestRunner()
runner.run(suite())

0 comments on commit 8a17419

Please sign in to comment.