From 7f7827dcfeda63051b2ea5ccc9094bb094a7a328 Mon Sep 17 00:00:00 2001 From: Catalina Syddall Date: Fri, 2 Aug 2019 17:52:47 -0300 Subject: [PATCH] fixing bugs on test --- data_scraper/test/test_cboe.py | 12 +++++++----- data_scraper/test/test_tiingo.py | 4 +--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data_scraper/test/test_cboe.py b/data_scraper/test/test_cboe.py index 204353a..76b9da1 100644 --- a/data_scraper/test/test_cboe.py +++ b/data_scraper/test/test_cboe.py @@ -54,7 +54,8 @@ class TestCBOE(unittest.TestCase): cboe.fetch_data(["FOOBAR"]) self.assertTrue(mocked_report.called) - @patch("data_scraper.cboe.url", new="http://non_existing_domain_expected_to_fail.com") + @patch("data_scraper.cboe.url", + new="http://non_existing_domain_expected_to_fail.com") @patch("data_scraper.cboe.send_report", return_value=None) def test_no_connection(self, mocked_notification): """Raise ConnectionError and send notification when host is unreachable""" @@ -70,15 +71,15 @@ class TestCBOE(unittest.TestCase): aggregate_file = os.path.join(TestCBOE.cboe_data_path, "SPX", "SPX_20190301_to_20190329.csv") self.addCleanup(TestCBOE.remove_files, os.path.dirname(aggregate_file)) - self.assertTrue(mocked_remove) + self.assertTrue(mocked_remove.called) self.assertTrue(mocked_report.called) - print(aggregate_file) if self.assertTrue(os.path.exists(aggregate_file)): spx_df = pd.read_csv(TestCBOE.spx_data_path) aggregate_df = pd.read_csv(aggregate_file) self.assertTrue(spx_df.equals(aggregate_df)) - - @patch("data_scraper.cboe.url", new="http://non_existing_domain_expected_to_fail.com") + + @patch("data_scraper.cboe.url", + new="http://non_existing_domain_expected_to_fail.com") @patch("data_scraper.cboe.retry_failure", return_value=None) def test_retry(self, mocked_retry): """Raise ConnectionError and retry when host is unreachable""" @@ -108,5 +109,6 @@ class TestCBOE(unittest.TestCase): if os.path.exists(file_path): shutil.rmtree(file_path) + if __name__ == "__main__": unittest.main() \ No newline at end of file diff --git a/data_scraper/test/test_tiingo.py b/data_scraper/test/test_tiingo.py index 3786698..e9e974e 100644 --- a/data_scraper/test/test_tiingo.py +++ b/data_scraper/test/test_tiingo.py @@ -27,13 +27,11 @@ class TestTiingo(unittest.TestCase): def tearDownClass(cls): if cls.save_data_path: os.environ["SAVE_DATA_PATH"] = cls.save_data_path - @patch("data_scraper.tiingo.send_report", return_value=None) def test_fetch_gld(self, mocked_notification): """Fetch GLD data""" tiingo.fetch_data(["GLD"]) - gld_dir = os.path.join(TestTiingo.tiingo_data_path, "GLD", "GLD_20190723.csv") - print(gld_dir) + gld_dir = os.path.join(TestTiingo.tiingo_data_path, "GLD") self.addCleanup(TestTiingo.remove_files, os.path.dirname(gld_dir)) if self.assertTrue(os.path.exists(gld_dir)):