def test_generate_export_path_export_proper_path(self): a_export_file_name = "export.p" a_relative_dataset_path = os.path.join(".", "file_name.p") actual = generate_export_path(a_relative_dataset_path, a_export_file_name) expected = os.path.join(".", a_export_file_name) self.assertEqual(actual, expected) an_absolute_dataset_path = os.path.join(self.temp_dir_obj.name, "an_export_file.p") actual = generate_export_path(an_absolute_dataset_path, a_export_file_name) expected = os.path.join(self.temp_dir_obj.name, a_export_file_name) self.assertEqual(actual, expected)
def test_integration_cpu(self): create_pickle_file(self.fake_data_path_pickle, predict_container=True) parse.main([ self.a_fasttext_model_type, self.fake_data_path_pickle, self.pickle_p_export_filename, "--device", self.cpu_device, ]) export_path = generate_export_path(self.fake_data_path_pickle, self.pickle_p_export_filename) self.assertTrue(os.path.isfile(export_path))
def test_integration_csv(self): create_csv_file(self.fake_data_path_csv, predict_container=True) parse.main([ self.a_fasttext_att_model_type, self.fake_data_path_csv, self.csv_export_filename, "--device", self.cpu_device, "--csv_column_name", "Address", ]) export_path = generate_export_path(self.fake_data_path_csv, self.csv_export_filename) self.assertTrue(os.path.isfile(export_path))
def test_integration_logging(self): with self._caplog.at_level(logging.INFO): create_pickle_file(self.fake_data_path_pickle, predict_container=True) parse.main([ self.a_fasttext_model_type, self.fake_data_path_pickle, self.pickle_p_export_filename, "--device", self.cpu_device, ]) expected_first_message = ( f"Parsing dataset file {self.fake_data_path_pickle} using the parser " f"FastTextAddressParser") actual_first_message = self._caplog.records[0].message self.assertEqual(expected_first_message, actual_first_message) export_path = generate_export_path(self.fake_data_path_pickle, "a_file.p") expected_second_message = ( f"4 addresses have been parsed.\n" f"The parsed addresses are outputted here: {export_path}") actual_second_message = self._caplog.records[1].message self.assertEqual(expected_second_message, actual_second_message)