aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_transform_lambda.py
diff options
context:
space:
mode:
authorAng Bel <anzelikabelotelova@Anzelikas-MacBook-Air.local>2024-08-21 12:50:32 +0100
committerAng Bel <anzelikabelotelova@Anzelikas-MacBook-Air.local>2024-08-21 12:50:32 +0100
commitb4fafcd9731f11f6f2efde843242b9c5cb84e85f (patch)
tree3219d4d91fa763334e62daad95c5d2436daf3d16 /tests/test_transform_lambda.py
parent8a67c688b402fae27d47399b3ae04cc8475f82b7 (diff)
downloadde-project-bentley-b4fafcd9731f11f6f2efde843242b9c5cb84e85f.tar.gz
de-project-bentley-b4fafcd9731f11f6f2efde843242b9c5cb84e85f.zip
function to write files from s3 into a list of dataframes. Current test is failing due to AioClientCreator object has no attribute "_inject_s3_input_parameters"
Diffstat (limited to 'tests/test_transform_lambda.py')
-rw-r--r--tests/test_transform_lambda.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/test_transform_lambda.py b/tests/test_transform_lambda.py
index dd08b6a..a3ec4a8 100644
--- a/tests/test_transform_lambda.py
+++ b/tests/test_transform_lambda.py
@@ -1 +1,33 @@
-from src.transform_lambda import lambda_handler \ No newline at end of file
+from src.transform_lambda import read_from_s3_subfolder_to_df
+from moto import mock_aws
+import pytest
+import pandas as pd
+import os
+import boto3
+
+@pytest.fixture(scope='class')
+def aws_credentials():
+ os.environ["AWS_ACCESS_KEY_ID"] = 'testing'
+ os.environ["AWS_SECRET_ACCESS_KEY"] = 'testing'
+ os.environ["AWS_SECURIT_TOKEN"] = 'testing'
+ os.environ["AWS_SESSION_TOKEN"] = 'testing'
+ os.environ["AWS_DEFAULT_REGION"]= 'eu-west-2'
+
+@pytest.fixture(scope='class')
+def s3_client(aws_credentials):
+ with mock_aws():
+ yield boto3.client('s3')
+class TestReadFromS3:
+
+ def test_returns_dictionary_with_correct_value_pair(self,s3_client):
+ s3_client.create_bucket(Bucket = 'dummy_buc',CreateBucketConfiguration={
+ 'LocationConstraint': 'eu-west-2'
+ })
+ s3_client.upload_file('tests/dummy_identical.csv', 'dummy_buc', 'Foods/2024/08/21/Foods_12:03:10.csv')
+ tables = ['Foods']
+ result = read_from_s3_subfolder_to_df(tables,bucket='dummy_buc',client=s3_client)
+ print(result)
+ assert isinstance(result,dict)
+ assert list(result.keys()) == 'Foods'
+ assert isinstance(result['Foods'],pd.DataFrame)
+ \ No newline at end of file
git.ajschof.me — hosted by ajschofield — powered by cgit