def test_file_size_partially_empty(self): instrument = InstrumentStrategy() path_file = os.path.join(instrument.temp_dir, '19BMTA2306_9-9-3-2-2020-RA1.txt') pdf = ('../pdf/d10/patient/5.00/19BMTA2306_9-9-3-2-2020-RA1.pdf',) instrument.convert_pdf(pdf) self.assertLess(200, os.stat(path_file).st_size)
def test_to_nested_happy_path(self): instrument = InstrumentStrategy() test_list = [ 'F', '1', '2', '3', '4', 'A1c', '1', '2', '3', '4', 'A1c', '1', '2', '3', '4', 'A1c', '1', '2', '3', '4', 'A1c', '1', '2', '3', '4', ] expected_list = [['F', '1', '2', '3', '4'], ['A1c', '1', '2', '3', '4'], ['A1c', '1', '2', '3', '4'], ['A1c', '1', '2', '3', '4'], [ 'A1c', '1', '2', '3', '4', ]] nested_test_list = instrument.to_nested(test_list) self.assertEqual(nested_test_list, expected_list)
def setUp(self): # initialize parsing algorithms self.instrument = InstrumentStrategy() self.d10 = D10Strategy() self.variant = VariantStrategy() self.nbs = NbsStrategy() # initialize pdf directories self.d10_patient_430 = '../pdf/d10/patient/4.30' self.d10_patient_500 = '../pdf/d10/patient/5.00' self.d10_control_430 = '../pdf/d10/control/4.30/test' self.variant_patient_a1c = '../pdf/variant/A1c' self.variant_patient_bthal = '../pdf/variant/BThal/patient' self.variant_control_bthal = '../pdf/variant/BThal/control' self.variant_patient_turbo_a1c = '../pdf/variant/Turbo A1c' self.vnbs_patient = '../pdf/vnbs/patient' # initialize save directory self.save_dir = os.path.abspath(os.getenv('programdata'))
def test_wrapper_decode_empty_array(self): arr_to_test = [] self.assertFalse(inst.wrapper_decode(self, arr_to_test))
def test_wrapper_decode_sad_path(self): arr_to_test = [b'one', b'two', b'three'] expected_result = ['one1', 'two2', 'three3'] self.assertNotEqual(expected_result, inst.wrapper_decode(self, arr_to_test))
class BuildCsvTestCase(unittest.TestCase): ''' tests the build_csv function''' def setUp(self): # initialize parsing algorithms self.instrument = InstrumentStrategy() self.d10 = D10Strategy() self.variant = VariantStrategy() self.nbs = NbsStrategy() # initialize pdf directories self.d10_patient_430 = '../pdf/d10/patient/4.30' self.d10_patient_500 = '../pdf/d10/patient/5.00' self.d10_control_430 = '../pdf/d10/control/4.30/test' self.variant_patient_a1c = '../pdf/variant/A1c' self.variant_patient_bthal = '../pdf/variant/BThal/patient' self.variant_control_bthal = '../pdf/variant/BThal/control' self.variant_patient_turbo_a1c = '../pdf/variant/Turbo A1c' self.vnbs_patient = '../pdf/vnbs/patient' # initialize save directory self.save_dir = os.path.abspath(os.getenv('programdata')) @unittest.skip('Skipping...') def test_csv_file(self): save = os.path.join(self.save_dir, 'one_entry.csv') self.instrument.convert_pdf_test(self.d10_dir) self.d10.build_csv(save) self.assertTrue(os.path.isfile(save)) @unittest.skip('Skipping...') def test_d10_50(self): save = os.path.join(self.save_dir, 'patient_D10_5.0.csv') self.instrument.convert_pdf_test(self.d10_dir) self.d10.build_csv(save) self.assertTrue(os.path.isfile(save)) @unittest.skip('Skipping...') def test_variant(self): save = os.path.join(self.save_dir, 'patient_variant.csv') self.instrument.convert_pdf_test(self.variant_patient_a1c) self.variant.build_csv(save) self.assertTrue(os.path.isfile(save)) @unittest.skip('Skipping...') def test_vnbs(self): save = os.path.join(self.save_dir, 'patient_vnbs.csv') self.instrument.convert_pdf_test(self.vnbs_patient) self.nbs.build_csv(save) self.assertTrue(os.path.isfile(save)) # @unittest.skip('Skipping...') def test_d10_patient_430(self): save = os.path.join(self.save_dir, 'patient_D10_4.30.csv') self.instrument.convert_pdf_test(self.d10_patient_430) self.d10.build_csv(save) self.assertTrue(os.path.isfile(save)) # @unittest.skip('Skipping...') def test_d10_patient_500(self): save = os.path.join(self.save_dir, 'patient_D10_5.00.csv') self.instrument.convert_pdf_test(self.d10_patient_500) self.d10.build_csv(save) self.assertTrue(os.path.isfile(save)) # @unittest.skip('Skipping...') def test_d10_control_430(self): save = os.path.join(self.save_dir, 'control_D10_4.30.csv') self.instrument.convert_pdf_test(self.d10_control_430) self.d10.build_csv(save) self.assertTrue(os.path.isfile(save))
def test_directory(self): instrumet = InstrumentStrategy() pdf = ('../pdf/d10/patient/5.00/19BMTA2306_9-9-3-2-2020-RA1.pdf',) instrumet.convert_pdf(pdf) self.assertTrue(os.path.isdir(instrumet.temp_dir))
def test_txt_file(self): instrument = InstrumentStrategy() pdf = ('../pdf/d10/patient/5.00/19BMTA2306_9-9-3-2-2020-RA1.pdf',) instrument.convert_pdf(pdf) self.assertTrue(os.path.isfile(os.path.join(instrument.temp_dir, '19BMTA2306_9-9-3-2-2020-RA1.txt')))
def test_rename_unknown_happy_path(self): test_list = ['Jonnel', 'Unknown', 'one'] expected_result = ['Jonnel', 'Unknown1', 'one'] inst.rename_unknown(self, test_list) self.assertEqual(test_list, expected_result)
def test_rename_unknown_no_unknowns(self): test_list = ['F', 'A1c', 'S', 'E', 'LA1c'] expected_result = 'There are no Unknowns in the list.' self.assertEqual(inst.rename_unknown(self, test_list), expected_result)
def test_rename_unknown_empty_list(self): test_list = [] expected_result = 'List is empty.' self.assertEqual(inst.rename_unknown(self, test_list), expected_result)
def test_rename_unknown_multiple_unknowns(self): test_list = ['Unknown', 'F', 'Unknown', 'A1c', 'Unknown'] expected_result = ['Unknown1', 'F', 'Unknown2', 'A1c', 'Unknown3'] inst.rename_unknown(self, test_list) self.assertEqual(test_list, expected_result)