def test_create_output_path_with_date(self, mock_datetime): expected = "/path/to/where/to/put/file-2011-10-06 09:21:20.724603.new" mock_datetime.now.return_value = datetime(2011, 10, 6, 9, 21, 20, 724603) result = create_output_path(self.new_extension, self.fake_path, self.test_out_directory, True) self.assertEqual(expected, result) result = create_output_path(self.new_extension, self.fake_path, self.test_out_directory + "/", True) self.assertEqual(expected, result)
def test_create_output_path(self): expected = "/path/to/where/to/put/file.new" result = create_output_path(self.new_extension, self.fake_path, self.test_out_directory) self.assertEqual(expected, result) result = create_output_path(self.new_extension, self.fake_path, self.test_out_directory + "/") self.assertEqual(expected, result)
def process_xml_directory(input_directory, hl7_directory, processed_file_dir=None): try: xml_files = hl7_importer_file_directory_utilities.process_directory("xml", input_directory) except IOError: error_message = "An error occurred trying to retrieve the xml file contents of the directory: %s." % ( input_directory ) gnumed_error_writer.write_error(error_message) exit(gnumed_error_writer.EXIT_FILE_OPERATION_ERROR) else: # Process each file. for n in xml_files: hl7_path = hl7_importer_file_directory_utilities.create_output_path("hl7", n, hl7_directory, True) process_xml_file(n, hl7_path) hl7_importer_file_directory_utilities.handle_processed_file(n, processed_file_dir)