class WritingExcelFile(unittest.TestCase): def setUp(self): self.whale = WhaleAlert(TEST_WORKING_DIR) self.config = self.whale.get_configuration() self.status = self.whale.get_status() self.database = self.whale.get_database() def tearDown(self): cleanup_working_directories() def test_return_false_if_no_working_directory(self): whale = WhaleAlert() success = whale.to_excel() self.assertEqual(success, False) def test_return_false_no_databases_exist(self): success = self.whale.to_excel() self.assertEqual(success, False) def test_writes_an_excel_file(self): self.whale.transactions.get_transactions = mock.MagicMock().method() self.whale.transactions.get_transactions.return_value = ( True, good_transactions, good_status) success = self.whale.fetch_and_store_data(0) success = self.whale.to_excel() exists = os.path.exists('whaleAlert.xlsx') self.assertEqual(exists, True) self.assertEqual(success, True) os.remove("whaleAlert.xlsx")
def test_return_false_if_no_working_directory(self): whale = WhaleAlert() success = whale.to_excel() self.assertEqual(success, False)