Ejemplo n.º 1
0
 def test_initialize_default_folders_and_files_where_home_path_exist_but_not_folder_dot_invoice(
         self):
     # initialize
     dir = tempfile.mkdtemp()
     invoice = Invoice()
     # test
     result = invoice.initialize_default_folders_and_files(dir)
     # verify
     self.assertEqual(len(result), 6)
     try:
         self.assertTrue(result.index("HOME_PATH_DOES_NOT_EXIST") >= 0)
         self.fail("ValueError expected.")
     except ValueError:
         pass
     self.assertTrue(result.index("HOME_PATH_DOES_EXIST") >= 0)
     dot_invoice_folder_path = join(dir, ".invoice")
     self.assertEqual(exists(dot_invoice_folder_path), True)
     self.assertTrue(result.index("DOT_INVOICE_FOLDER_CREATED") >= 0)
     invoice_file_path = join(dot_invoice_folder_path, "invoice.txt")
     self.assertEqual(exists(invoice_file_path), True)
     self.assertTrue(result.index("INVOICE_FILE_CREATED") >= 0)
     company_file_path = join(dot_invoice_folder_path, "company.txt")
     self.assertEqual(exists(company_file_path), True)
     self.assertTrue(result.index("COMPANY_FILE_CREATED") >= 0)
     automatic_invoice_file_path = join(dot_invoice_folder_path,
                                        "automatic_invoice.txt")
     self.assertEqual(exists(automatic_invoice_file_path), True)
     self.assertTrue(result.index("AUTOMATIC_INVOICE_FILE_CREATED") >= 0)
     periodic_invoice_file_path = join(dot_invoice_folder_path,
                                       "periodic_invoice.txt")
     self.assertEqual(exists(periodic_invoice_file_path), True)
     self.assertTrue(result.index("PERIODIC_INVOICE_FILE_CREATED") >= 0)
     # cleanup
     shutil.rmtree(dir)
     return
Ejemplo n.º 2
0
 def test_initialize_default_folders_and_files_where_home_path_does_not_exist(
         self):
     # initialize
     dir = dirname("/THIS/PATH/DOES/NOT/EXIST")
     invoice = Invoice()
     # test
     result = invoice.initialize_default_folders_and_files(dir)
     # verify
     self.assertTrue(result.index("HOME_PATH_DOES_NOT_EXIST") >= 0)
     return
Ejemplo n.º 3
0
 def test_initialize_default_folders_and_files_where_dot_invoice_folder_and_all_files_exist(
         self):
     # initialize
     dir = tempfile.mkdtemp()
     self.create_default_files_and_folders(dir)
     invoice = Invoice()
     # test
     result = invoice.initialize_default_folders_and_files(dir)
     # verify
     self.assertEqual(len(result), 1)
     try:
         self.assertTrue(result.index("HOME_PATH_DOES_NOT_EXIST") >= 0)
         self.fail("ValueError expected.")
     except ValueError:
         pass
     self.assertTrue(result.index("HOME_PATH_DOES_EXIST") >= 0)
     dot_invoice_folder_path = join(dir, ".invoice")
     self.assertEqual(exists(dot_invoice_folder_path), True)
     invoice_file_path = join(dot_invoice_folder_path, "invoice.txt")
     self.assertEqual(exists(invoice_file_path), True)
     # cleanup
     shutil.rmtree(dir)
     return