def test_age_less_150(self): """ This test case is for us07 """ docs_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) a = Repository("Project01_Xiaomeng Xu.ged", os.path.join(docs_dir, 'docs')) self.assertEqual(a.us07_age_less_150(), [ "ANOMALY: US07: Individual@I7@> didn't record age"])
def test_birth_b4_now(self): docs_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) a = Repository(filename='Project01_Xiaomeng Xu.ged', dir_path=os.path.join(docs_dir, 'docs')) current_time = datetime.datetime.now() for result in a.us_01_birth_b4_now(): with self.subTest(): self.assertLess((result - current_time).days, 0) self.assertGreater((current_time - result).days, 0) self.assertTrue((current_time - result).days > 0) self.assertFalse((current_time - result).days < 0)
#!/usr/bin/env python # coding=UTF-8 ''' @Author: Puzhuo Li @Github: https://github.com/JamesLi0217 @Date: 2019-04-07 00:44:27 ''' import unittest import sys import os from GED import Repository docs_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) a = Repository(filename='Project_t17.ged', dir_path=os.path.join(docs_dir, 'docs')) '''path = r"/Users/daiyuping/Documents/GitHub/SSW555_TeamPrj/docs" filename = r"Project_t17.ged" a = Repository(filename=filename, dir_path=path)''' class Test_us17_No_marriages_to_children(unittest.TestCase): """Tests conducted on file 'Project_t17.ged' """ def test_US17_No_marriages_to_children(self): """Test No_marriages_to_children()""" self.assertEqual(a.us17_No_marriages_to_children(), [ "ERROR: US17: FAMILY @F5@ father @I7@> marriages to children ['@I7@']" ])
import unittest import datetime import sys import os from GED import Repository docs_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) a = Repository(filename='what_a_mass.ged', dir_path=os.path.join(docs_dir, 'docs')) class Test_us31_list_living_single(unittest.TestCase): """Tests conducted on file 'what_a_mass.ged'""" def test_us31_list_living_single(self): """Test us31_list_living_single()""" self.assertEqual(a.us31_list_living_single(), []) b = Repository(filename='Project_t31.ged', dir_path=os.path.join(docs_dir, 'docs')) class Test_us31_list_living_single(unittest.TestCase): """Tests conducted on file 'Project_t31.ged'""" def test_us31_list_living_single(self): """Test us31_list_living_single()""" self.assertEqual(b.us31_list_living_single(), ['@I10@', '@I16@']) if __name__ == '__main__': print('Running unit tests')
#!/usr/bin/env python # coding=UTF-8 ''' @Author: Puzhuo Li @Github: https://github.com/JamesLi0217 @Date: 2019-04-05 23:15:39 ''' import unittest import datetime import sys import os from GED import Repository docs_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) a = Repository(filename='Project01_Xiaomeng Xu.ged', dir_path=os.path.join(docs_dir, 'docs')) class Test_us_10_01(unittest.TestCase): """Test conducnt on file 'Project01_Xiaomeng Xu.ged""" def test_family_01(self): """Test us10_marriage_after_14() on family 1""" self.assertEqual(a.us10_marriage_after_14(), [ "ANOMALY: US10: Family@F1@> can't compare if parents are at least 14 years old", "ANOMALY: US10: Family@F2@> can't compare if parents are at least 14 years old" ]) if __name__ == '__main__': print('Running unit tests') unittest.main(exit=False, verbosity=2)
import unittest import sys import os from GED import Repository a = Repository( filename='Project01_Pli.ged', dir_path='/home/travis/build/SamNormcoreWayne/SSW555_TeamPrj/docs') b = Repository( filename='Project01_Xiaomeng Xu.ged', dir_path='/home/travis/build/SamNormcoreWayne/SSW555_TeamPrj/docs') c = Repository( filename='Project02.ged', dir_path='/home/travis/build/SamNormcoreWayne/SSW555_TeamPrj/docs') d = Repository( filename='Project_t03.ged', dir_path='/home/travis/build/SamNormcoreWayne/SSW555_TeamPrj/docs') e = Repository( filename='Project_t04.ged', dir_path='/home/travis/build/SamNormcoreWayne/SSW555_TeamPrj/docs') f = Repository( filename='Project_t10.ged', dir_path='/home/travis/build/SamNormcoreWayne/SSW555_TeamPrj/docs') g = Repository( filename='Project_t16.ged', dir_path='/home/travis/build/SamNormcoreWayne/SSW555_TeamPrj/docs') h = Repository( filename='Project_t15.ged', dir_path='/home/travis/build/SamNormcoreWayne/SSW555_TeamPrj/docs')
import unittest import os from GED import Repository if __name__ == "__main__": test_dir = os.path.join(os.getcwd(), "tests") print(os.getcwd()) discover = unittest.defaultTestLoader.discover(test_dir, 'TestGED_*.py') docs_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) report_path = os.path.join(docs_dir, 'docs', 'report.txt') a = Repository(filename='Project01_Xiaomeng Xu.ged', dir_path=os.path.join(docs_dir, 'docs')) with open(report_path, 'w') as report: report.write(a.individual_pt()) report.write(a.output_family()) runner = unittest.TextTestRunner(stream=report, verbosity=2) runner.run(discover)
"""Unitest for user story 02""" import unittest from GED import Repository import os docs_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) GED1 = Repository(filename='Project01_Xiaomeng Xu.ged', dir_path=os.path.join(docs_dir, 'docs')) GED2 = Repository(filename='TestGED_us02.ged', dir_path=os.path.join(docs_dir, 'docs')) class Test_us02_birth_b4_marriage(unittest.TestCase): """This are the test cases for user story_02: check if a individual's birthday is before marriage date.""" def test_GED1(self): """Testing function on file: Project01_Xiaomeng Xu.ged""" self.assertEqual(GED1.us02_birth_b4_marriage(), []) def test_GED2(self): """Testing function on file: TestGED_us02.ged""" self.assertEqual(GED2.us02_birth_b4_marriage(), [ 'ANOMALY: FAMILY:<@F2@>', 'ANOMALY: FAMILY:<@F3@>', 'ANOMALY: FAMILY:<@F4@>' ]) if __name__ == '__main__': print('Running unit tests') unittest.main(exit=False, verbosity=2)
#!/usr/bin/env python # coding=UTF-8 ''' @Author: Puzhuo Li @Github: https://github.com/JamesLi0217 @Date: 2019-03-23 21:55:01 ''' import unittest import sys import os from GED import Repository docs_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) b = Repository(filename='Project01_Xiaomeng Xu.ged', dir_path=os.path.join(docs_dir, 'docs')) c = Repository(filename='Project02.ged', dir_path=os.path.join(docs_dir, 'docs')) d = Repository(filename='Project_t03.ged', dir_path=os.path.join(docs_dir, 'docs')) e = Repository(filename='Project_t04.ged', dir_path=os.path.join(docs_dir, 'docs')) f = Repository(filename='Project_t10.ged', dir_path=os.path.join(docs_dir, 'docs')) # g = Repository(filename='Project01_us12_Pli.ged', # dir_path=os.path.join(docs_dir, 'docs')) class Test_us12_01(unittest.TestCase): """Tests conducted on file 'Project01_Pli.ged' 'Project01_Xiaomeng Xu.ged'