aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEllie <ecsymonds@gmail.com>2024-08-19 15:57:14 +0100
committerEllie <ecsymonds@gmail.com>2024-08-19 15:57:14 +0100
commite4b66476a174edb68992b00b37bef2d0e0be3969 (patch)
tree078bb6d6767752e5426295388e52aa0e9f9639c4 /tests
parentc3c45c0d133ce32d48f1c72a0ac54f291038b1e7 (diff)
downloadde-project-bentley-e4b66476a174edb68992b00b37bef2d0e0be3969.tar.gz
de-project-bentley-e4b66476a174edb68992b00b37bef2d0e0be3969.zip
wip: fixing last test
Diffstat (limited to 'tests')
-rw-r--r--tests/test_extract_lambda.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/test_extract_lambda.py b/tests/test_extract_lambda.py
index 4a5157b..01d7add 100644
--- a/tests/test_extract_lambda.py
+++ b/tests/test_extract_lambda.py
@@ -181,24 +181,27 @@ class TestProcessAndUploadTables:
def test_error_process_and_upload_tables(mock_conn, s3_client, caplog):
logger = logging.getLogger()
logger.info('Testing now.')
- caplog.set_level(logging.ERROR)
+ caplog.set_level(logging.INFO)
####
- queries = ["SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE';",
- "SELECT * FROM Fruits;",
- "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS where table_name = 'Fruits'"]
+ queries = [
+ "SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE';",
+ "SELECT * FROM Fruits;",
+ "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS where table_name = 'Fruits'"
+ ]
return_values = [[['Fruits']],
- [['Vegetable','Sour','Green'],['Berry','Sweet','Red']],
- [['Food_type'],['Flavour'],['Colour']]] # why are individual column names in lists
+ [['Vegetable','Sour','Green','2022-11-03 14:20:49.962'],['Berry','Sweet','Red','2022-11-03 14:20:49.962']],
+ [['Food_type'],['Flavour'],['Colour'],['last_updated']]] # why are individual column names in lists
vals = dict(zip(queries,return_values))
# {"SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE';": [['Fruits']], 'SELECT * FROM Fruits;': [['Vegetable', 'Sour', 'Green'], ['Berry', 'Sweet', 'Red']], "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS where table_name = 'Fruits'": [['Food_type'], ['Flavour'], ['Colour']]}
with patch('src.extract_lambda.Connection') as mock_db:
mock_db().run.side_effect = return_values
s3_key = 'Fruits/2024/08/15/Fruits_16:46:30.csv'
- existing_files = {s3_key: 'Food_type,Flavour,Colour\nFruit,Sour,Green\nBerry,Sweet,Red'}
+ existing_files = {s3_key: 'Food_type,Flavour,Colour,last_updated\nVegetable,Sour,Green,2022-11-03 14:20:49.962\nBerry,Sweet,Red, 2022-11-03 14:20:49.962'}
s3_client.create_bucket(Bucket='test_extract_bucket',
CreateBucketConfiguration={'LocationConstraint': 'eu-west-2'})
- print(s3_client.list_buckets)
- s3_client.upload_file('tests/dummy_identical.csv', 'extract_bucket', s3_key)
+ s3_client.upload_file('tests/dummy_identical.csv', 'test_extract_bucket', s3_key)
process_and_upload_tables(mock_db(), existing_files, client=s3_client)
- assert 'No new data.' in caplog.text \ No newline at end of file
+ print('logger', logger.info('hello'))
+ print('our test', caplog.text)
+ assert 'No new data' in caplog.text \ No newline at end of file
git.ajschof.me — hosted by ajschofield — powered by cgit