From e4b66476a174edb68992b00b37bef2d0e0be3969 Mon Sep 17 00:00:00 2001 From: Ellie Date: Mon, 19 Aug 2024 15:57:14 +0100 Subject: wip: fixing last test --- tests/test_extract_lambda.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'tests/test_extract_lambda.py') 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 -- cgit v1.2.3