Skip to content

Commit

Permalink
refactor: simplify code in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfouquet committed Feb 2, 2024
1 parent 706400c commit 6ca8cfb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/files/tests/fs_s3_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ def test_exists_object_starting_with_not_exists() -> None:

@mock_s3 # type: ignore
def test_list_files_in_uri() -> None:
bucket_name = "testbucket"
s3 = resource("s3", region_name=DEFAULT_REGION_NAME)
boto3_client = client("s3", region_name=DEFAULT_REGION_NAME)
s3.create_bucket(Bucket="testbucket")
boto3_client.put_object(Bucket="testbucket", Key="data/collection.json", Body=b"test content")
boto3_client.put_object(Bucket="testbucket", Key="data/image.tiff", Body=b"test content")
boto3_client.put_object(Bucket="testbucket", Key="data/image_meta.xml", Body=b"test content")
s3.create_bucket(Bucket=bucket_name)
boto3_client.put_object(Bucket=bucket_name, Key="data/collection.json", Body=b"")
boto3_client.put_object(Bucket=bucket_name, Key="data/image.tiff", Body=b"")
boto3_client.put_object(Bucket=bucket_name, Key="data/image_meta.xml", Body=b"")

files = list_files_in_uri("s3://testbucket/data/", [".json", "_meta.xml"], boto3_client)

assert len(files) == 2
assert "data/collection.json" in files
assert "data/image_meta.xml" in files
assert set(files) == {"data/collection.json", "data/image_meta.xml"}
assert "data/image.tiff" not in files

0 comments on commit 6ca8cfb

Please sign in to comment.