Skip to content

Commit

Permalink
Merge pull request #27 from Victoremepunto/fix-small-test-bug
Browse files Browse the repository at this point in the history
Small test bugfixes
  • Loading branch information
Victoremepunto authored Jun 3, 2022
2 parents f091d90 + e9ddcda commit ae2b896
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/test_floorist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import boto3
import pytest
import yaml
import logging

from botocore.exceptions import NoCredentialsError
from floorist.floorist import main
Expand All @@ -18,6 +19,10 @@ def setup_env(self):
for key in settings:
env[key] = settings[key]

@pytest.fixture(autouse=True)
def setup_caplog(self, caplog):
caplog.set_level(logging.INFO)

@pytest.fixture(autouse=False)
def session(self):
prefix = f"s3://{env['AWS_BUCKET']}"
Expand Down Expand Up @@ -145,14 +150,14 @@ def test_floorplan_with_multiple_dumps(self, caplog, session):
prefix = f"s3://{env['AWS_BUCKET']}"
env['FLOORPLAN_FILE'] = 'tests/floorplan_with_multiple_dumps.yaml'
main()
assert 'Dumped 2 from total of 2'
assert 'Dumped 2 from total of 2' in caplog.text
assert wr.s3.list_directories(prefix, boto3_session=session) == [f"{prefix}/numbers/", f"{prefix}/people/"]

def test_floorplan_with_large_result(self, caplog, session):
prefix = f"s3://{env['AWS_BUCKET']}"
env['FLOORPLAN_FILE'] = 'tests/floorplan_with_large_result.yaml'
main()
assert 'Dumped 1 from total of 1'
assert 'Dumped 1 from total of 1' in caplog.text
assert wr.s3.list_directories(prefix, boto3_session=session) == [f"{prefix}/series/"]
assert len(wr.s3.list_objects(f"{prefix}/series/", boto3_session=session)) == 1000
df = wr.s3.read_parquet(f"{prefix}/series/", boto3_session=session)
Expand All @@ -162,7 +167,7 @@ def test_floorplan_with_custom_chunksize(self, caplog, session):
prefix = f"s3://{env['AWS_BUCKET']}"
env['FLOORPLAN_FILE'] = 'tests/floorplan_with_custom_chunksize.yaml'
main()
assert 'Dumped 1 from total of 1'
assert 'Dumped 1 from total of 1' in caplog.text
assert wr.s3.list_directories(prefix, boto3_session=session) == [f"{prefix}/series/"]
assert len(wr.s3.list_objects(f"{prefix}/series/", boto3_session=session)) == 77
df = wr.s3.read_parquet(f"{prefix}/series/", boto3_session=session)
Expand All @@ -175,14 +180,14 @@ def test_floorplan_with_one_failing_dump(self, caplog, session):
main()
assert ex.value.code == 1
assert 'ProgrammingError' in caplog.text
assert 'Dumped 1 from total of 2'
assert 'Dumped 1 from total of 2' in caplog.text
assert wr.s3.list_directories(prefix, boto3_session=session) == [f"{prefix}/numbers/"]

def test_floorplan_valid(self, caplog, session):
prefix = f"s3://{env['AWS_BUCKET']}"
env['FLOORPLAN_FILE'] = 'tests/floorplan_valid.yaml'
main()
assert 'Dumped 1 from total of 1'
assert 'Dumped 1 from total of 1' in caplog.text
assert wr.s3.list_directories(prefix, boto3_session=session) == [f"{prefix}/valid/"]
assert len(wr.s3.list_objects(f"{prefix}/valid/", boto3_session=session)) == 1
df = wr.s3.read_parquet(f"{prefix}/valid/", boto3_session=session)
Expand Down

0 comments on commit ae2b896

Please sign in to comment.