From 44147b52191681092d1ac0ee538b9e107bcb7474 Mon Sep 17 00:00:00 2001 From: JosephKevinMachado Date: Mon, 17 Jun 2024 13:54:44 -0400 Subject: [PATCH] 2024-06-17-13-54-44 - remove-migrations --- ...20221022_01_pvLdZ-create-bitcoin-schema.py | 10 --- ...20221022_02_ivvG9-create-exchange-table.py | 28 ------ .../test_exchange_data_etl_integration.py | 89 ++++++++++--------- 3 files changed, 45 insertions(+), 82 deletions(-) delete mode 100644 migrations/20221022_01_pvLdZ-create-bitcoin-schema.py delete mode 100644 migrations/20221022_02_ivvG9-create-exchange-table.py diff --git a/migrations/20221022_01_pvLdZ-create-bitcoin-schema.py b/migrations/20221022_01_pvLdZ-create-bitcoin-schema.py deleted file mode 100644 index 95ae09d..0000000 --- a/migrations/20221022_01_pvLdZ-create-bitcoin-schema.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -create bitcoin schema -""" -from typing import Any - -from yoyo import step - -__depends__: Any = {} - -steps = [step("CREATE SCHEMA bitcoin", "DROP SCHEMA bitcoin")] diff --git a/migrations/20221022_02_ivvG9-create-exchange-table.py b/migrations/20221022_02_ivvG9-create-exchange-table.py deleted file mode 100644 index 71bf66e..0000000 --- a/migrations/20221022_02_ivvG9-create-exchange-table.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -create exchange table -""" - -from yoyo import step - -__depends__ = {"20221022_01_pvLdZ-create-bitcoin-schema"} - -steps = [ - step( - """ - CREATE TABLE bitcoin.exchange - ( - id VARCHAR(50), - name VARCHAR(50), - rank INT, - percentTotalVolume NUMERIC(8, 5), - volumeUsd NUMERIC(18, 5), - tradingPairs INT, - socket BOOLEAN, - exchangeUrl VARCHAR(50), - updated_unix_millis BIGINT, - updated_utc TIMESTAMP - ) - """, - "DROP TABLE bitcoin.exchange", - ) -] diff --git a/test/integration/test_exchange_data_etl_integration.py b/test/integration/test_exchange_data_etl_integration.py index 908a21c..6096998 100644 --- a/test/integration/test_exchange_data_etl_integration.py +++ b/test/integration/test_exchange_data_etl_integration.py @@ -21,7 +21,7 @@ def get_exchange_data(self): cursor_factory=psycopg2.extras.DictCursor ) as curr: curr.execute( - '''SELECT id, + """SELECT id, name, rank, percenttotalvolume, @@ -31,79 +31,80 @@ def get_exchange_data(self): exchangeurl, updated_unix_millis, updated_utc - FROM bitcoin.exchange;''' + FROM bitcoin.exchange;""" ) table_data = [dict(r) for r in curr.fetchall()] return table_data def test_exchange_data_etl_run(self, mocker): mocker.patch( - 'bitcoinmonitor.exchange_data_etl.get_exchange_data', + "bitcoinmonitor.exchange_data_etl.get_exchange_data", return_value=[ r for r in csv.DictReader( - open('test/fixtures/sample_raw_exchange_data.csv') + open("test/fixtures/sample_raw_exchange_data.csv") ) ], ) run() expected_result = [ { - 'id': 'binance', - 'name': 'Binance', - 'rank': 1, - 'percenttotalvolume': Decimal('25.44443'), - 'volumeusd': Decimal('12712561147.79130'), - 'tradingpairs': 650, - 'socket': True, - 'exchangeurl': 'https://www.binance.com/', - 'updated_unix_millis': 1625787943298, - 'updated_utc': datetime.datetime( + "id": "binance", + "name": "Binance", + "rank": 1, + "percenttotalvolume": Decimal("25.44443"), + "volumeusd": Decimal("12712561147.79130"), + "tradingpairs": 650, + "socket": True, + "exchangeurl": "https://www.binance.com/", + "updated_unix_millis": 1625787943298, + "updated_utc": datetime.datetime( 2021, 7, 8, 23, 45, 43, 298000 ), }, { - 'id': 'zg', - 'name': 'ZG.com', - 'rank': 2, - 'percenttotalvolume': Decimal('13.03445'), - 'volumeusd': Decimal('6512276458.52265'), - 'tradingpairs': 133, - 'socket': False, - 'exchangeurl': 'https://api.zg.com/', - 'updated_unix_millis': 1625787941554, - 'updated_utc': datetime.datetime( + "id": "zg", + "name": "ZG.com", + "rank": 2, + "percenttotalvolume": Decimal("13.03445"), + "volumeusd": Decimal("6512276458.52265"), + "tradingpairs": 133, + "socket": False, + "exchangeurl": "https://api.zg.com/", + "updated_unix_millis": 1625787941554, + "updated_utc": datetime.datetime( 2021, 7, 8, 23, 45, 41, 554000 ), }, { - 'id': 'huobi', - 'name': 'Huobi', - 'rank': 3, - 'percenttotalvolume': Decimal('5.93652'), - 'volumeusd': Decimal('2966009471.83377'), - 'tradingpairs': 589, - 'socket': True, - 'exchangeurl': 'https://www.hbg.com/', - 'updated_unix_millis': 1625787943276, - 'updated_utc': datetime.datetime( + "id": "huobi", + "name": "Huobi", + "rank": 3, + "percenttotalvolume": Decimal("5.93652"), + "volumeusd": Decimal("2966009471.83377"), + "tradingpairs": 589, + "socket": True, + "exchangeurl": "https://www.hbg.com/", + "updated_unix_millis": 1625787943276, + "updated_utc": datetime.datetime( 2021, 7, 8, 23, 45, 43, 276000 ), }, { - 'id': 'okex', - 'name': 'Okex', - 'rank': 4, - 'percenttotalvolume': Decimal('4.99990'), - 'volumeusd': Decimal('2498051785.36013'), - 'tradingpairs': 287, - 'socket': False, - 'exchangeurl': 'https://www.okex.com/', - 'updated_unix_millis': 1625787941641, - 'updated_utc': datetime.datetime( + "id": "okex", + "name": "Okex", + "rank": 4, + "percenttotalvolume": Decimal("4.99990"), + "volumeusd": Decimal("2498051785.36013"), + "tradingpairs": 287, + "socket": False, + "exchangeurl": "https://www.okex.com/", + "updated_unix_millis": 1625787941641, + "updated_utc": datetime.datetime( 2021, 7, 8, 23, 45, 41, 641000 ), }, ] result = self.get_exchange_data() + print(result) assert expected_result == result