예제 #1
0
 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"))
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 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)
예제 #7
0
 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"))
예제 #8
0
 def test_process_line(self):
     store = Store()
     self.assertFalse(store.process_line("test", []))
예제 #9
0
 def test_get_split_char(self):
     store = Store()
     self.assertEquals(",", store.get_split_char())
예제 #10
0
 def test_init(self):
     store = Store()
     self.assertIsNotNone(store)
예제 #11
0
 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)
예제 #12
0
 def test_get_file_processor_unknown(self):
     store = Store()
     with self.assertRaises(Exception):
         store.get_file_processor("UNKNOWN")
예제 #13
0
 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)