Example #1
0
def setup_and_teardown(bucket: str):
    """
    Anything before yield executed before the test
    Anything after yield executed after the test
    """
    logging.info("Create bucket")
    s3.create_bucket(bucket)
    yield
    logging.info("Delete bucket")
    s3.delete_bucket(bucket)
def prepare_bucket(bucket):
    """
    Anything before yield executed before the test
    Anything after yield executed after the test
    """
    logging.info("Create bucket")
    s3.create_bucket(bucket)
    yield
    logging.info("Delete bucket")
    s3.delete_bucket(bucket)
def setup_and_teardown(xml_bucket: str, json_bucket: str):
    """
    Anything before yield executed before the test
    Anything after yield executed after the test
    """
    logging.info("Setting up: create s3 and dynamodb resources")
    s3.create_bucket(xml_bucket)
    s3.create_bucket(json_bucket)
    with open("test/mock_data/data.xml", 'rb') as f:
        data = f.read().decode('utf-8')
    s3.put_object(xml_bucket, "data.xml", data)
    # dynamo create table
    db.create_rules_table("TestProcessingRules")
    # dynamo load data
    with open("test/mock_data/rules.json", 'rb') as f:
        fake_rules = json.load(f)
    db.load_rules(fake_rules, "TestProcessingRules")
    yield
    logging.info("Tearing down: delete s3 and dynamodb resources")
    s3.delete_bucket(xml_bucket)
    s3.delete_bucket(json_bucket)
    # dynamo remove table
    db.delete_table("TestProcessingRules")
def test_delete_bucket():
    bucket = "test-del-bucket"
    s3.create_bucket(bucket)
    s3.delete_bucket(bucket)
    assert bucket not in s3.list_buckets()
def test_create_bucket(prepare_bucket, bucket: str):
    s3.create_bucket(bucket)
    assert bucket in s3.list_buckets()