def test_split_into_fields(self): store = Store() self.assertEquals(["FIELD1"], store.split_into_fields("FIELD1")) self.assertEquals(["FIELD1", "FIELD2"], store.split_into_fields("FIELD1,FIELD2")) self.assertEquals(["FIELD1", "FIELD2", "FIELD3"], store.split_into_fields("FIELD1,FIELD2,FIELD3"))
def test_get_file_processor_csv(self): store = Store() self.assertIsInstance( store.get_file_processor( Store.CSV_FORMAT, os.path.dirname(__file__) + os.sep + "test.csv"), CSVFileReader)
def test_upload_from_directory_without_subdir_with_ext(self): store = Store() final_count, final_success = store.upload_from_directory( os.path.dirname(__file__) + os.sep + "testdir", subdir=False, extension=".txt") self.assertEquals(2, final_count) self.assertEquals(0, final_success)
def test_upload_from_directory_with_subdir_no_commit(self): store = Store() final_count, final_success = store.upload_from_directory( os.path.dirname(__file__) + os.sep + "testdir", subdir=True, commit=False) self.assertEquals(5, final_count) self.assertEquals(0, final_success)
def test_get_file_processor_other(self): store = Store() with self.assertRaises(Exception): self.assertIsInstance( store.get_file_processor( "other", os.path.dirname(__file__) + os.sep + "test.csv"), CSVFileReader)
def test_upload_from_directory_exception_no_commit(self): store = Store() final_count, final_success = store.upload_from_directory( os.path.dirname(__file__) + os.sep + "testdir", subdir=False, extension=".txt", commit=False) self.assertEquals(0, final_count) self.assertEquals(0, final_success)
def test_get_just_filename_from_filepath(self): store = Store() self.assertEqual("", store.get_just_filename_from_filepath("")) self.assertEqual("TEST", store.get_just_filename_from_filepath("test")) self.assertEqual("TEST", store.get_just_filename_from_filepath("test.txt")) self.assertEqual( "TEST", store.get_just_filename_from_filepath( os.path.dirname(__file__) + os.sep + "test.txt"))
def test_process_line(self): store = Store() self.assertFalse(store.process_line("test", []))
def test_get_split_char(self): store = Store() self.assertEquals(",", store.get_split_char())
def test_init(self): store = Store() self.assertIsNotNone(store)
def test_upload_from_file_fileprocessor_none(self): store = Store() final_count, final_success = store.upload_from_file( os.path.dirname(__file__) + os.sep + "testdir") self.assertEquals(0, final_count) self.assertEquals(0, final_success)
def test_get_file_processor_unknown(self): store = Store() with self.assertRaises(Exception): store.get_file_processor("UNKNOWN")
def test_get_file_processor_text(self): store = Store() self.assertIsInstance( store.get_file_processor( Store.TEXT_FORMAT, os.path.dirname(__file__) + os.sep + "test.txt"), TextFile)