Ejemplo n.º 1
0
def test_get_latest_ver_of_obj():
    key = "test_get_latest_ver.json"
    bucket = Bucket(bucket=ver_bucket, key=key)
    i = 0
    while i < 5:
        data = list(range(0, i**2))
        data = {"data": data}
        bucket.put(data)
        state = bucket.get()
        assert data == state
        i += 1
Ejemplo n.º 2
0
def test_put_dict_to_lambda_w_encoder(data):
    bucket = Bucket(key=key,
                    region=region,
                    bucket=s3_bucket,
                    decoder=datetime_decoder,
                    encoder=datetime_encoder)

    resp = bucket.put(data)

    assert resp.bucket_name == s3_bucket

    bucket_res = bucket.get()
    assert bucket_res == data
Ejemplo n.º 3
0
def test_is_versioning_enabled(bucket):
    bkt = Bucket(bucket=ver_bucket)
    res = bkt.is_versioning_enabled()
    assert res

    bkt = Bucket(bucket=s3_bucket)
    bkt.disable_versioning()
    res = bkt.is_versioning_enabled()
    assert not res
Ejemplo n.º 4
0
def test_access_denied_for_bucket():
    with pytest.raises(ClientError):
        Bucket(bucket="example")
Ejemplo n.º 5
0
def test_bucket_does_not_exist():
    with pytest.raises(ClientError):
        Bucket(bucket="example-awsjar-non-existent-bucket-353412312513",
               key=key)
Ejemplo n.º 6
0
def bucket():
    return Bucket(key=key, region=region, bucket=s3_bucket)
Ejemplo n.º 7
0
def test_put_dict_w_pretty(data):
    bkt = Bucket(key=key, region=region, bucket=s3_bucket, pretty=True)
    bkt.put(data)
    state = bkt.get()
    assert data == state
Ejemplo n.º 8
0
def test_repr():
    bucket = Bucket(bucket=s3_bucket, key="does_not_exist")
    assert repr(
        bucket
    ) == "Bucket(bucket='awsjar-testing-regular-bucket', key='does_not_exist')"
Ejemplo n.º 9
0
def test_str():
    bucket = Bucket(bucket=s3_bucket, key="does_not_exist")
    assert str(bucket) == "s3://awsjar-testing-regular-bucket/does_not_exist"
Ejemplo n.º 10
0
def test_ver_obj_does_not_exist():
    bucket = Bucket(bucket=ver_bucket, key="does_not_exist")
    state = bucket.get()
    assert state == {}
Ejemplo n.º 11
0
def test_get_latest_ver_of_obj_errors_for_invalid_key():
    bkt = Bucket(bucket=ver_bucket, key="non-existent-object")
    v = bkt._get_latest_ver_id_of_obj()
    assert v is None
Ejemplo n.º 12
0
def test_get_latest_ver_id_of_obj():
    bkt = Bucket(bucket=ver_bucket,
                 key="test_get_latest_ver_id_of_obj_dont_edit")
    v = bkt._get_latest_ver_id_of_obj()
    assert v.id == "l889rYbHoTeSGRffAv_epr_MGgPwBRW4"
Ejemplo n.º 13
0
def test_get_ver_id_of_non_ver_object():
    """ Non versioned objects have id of null """
    bkt = Bucket(bucket="awsjar-testing-regular-bucket",
                 key="object-with-no-versions")
    ver_id = bkt._get_latest_ver_id_of_obj().id
    assert ver_id == "null"
Ejemplo n.º 14
0
def test_access_denied_for_obj():
    with pytest.raises(ClientError):
        bkt = Bucket(bucket="awsjar-testing-forbidden-objects",
                     key="forbidden-object")
        bkt.get()