Ejemplo n.º 1
0
def test_expand_json(moto_boto):

    session = IrisSessionData()
    session.store_shared_json_data(expansion_data.SHARED_ID,
                                   expansion_data.SHARED_JSON)
    expanded_data = session.expand_json_obj(expansion_data.EXPANSION_JSON)
    assert expanded_data == expansion_data.EXPANDED_JSON
Ejemplo n.º 2
0
def test_store_retrieve_json_data(moto_boto):

    session = IrisSessionData()
    session.store_json_data(expansion_data.ID1, expansion_data.TEST_JSON_1)

    # check result
    result = session.get_json_data(expansion_data.ID1)

    assert result == expansion_data.TEST_JSON_1
Ejemplo n.º 3
0
def test_store_retrieve_shared_json_data(moto_boto):

    # setup
    test_content = json.dumps(expansion_data.TEST_JSON_1)

    # run test
    session = IrisSessionData()
    session.store_shared_json_data(expansion_data.ID1, test_content)

    # check result
    result = session.get_shared_json_data(expansion_data.ID1)

    assert result == test_content
Ejemplo n.º 4
0
def test_store_shared_json_data(moto_boto):

    # run test
    session = IrisSessionData()
    session.store_shared_json_data(expansion_data.ID1,
                                   expansion_data.TEST_JSON_1)

    # check result
    key_name = "shared/" + expansion_data.ID1
    s3 = moto_boto[1]
    bucket = s3.Bucket(iris_settings.IRIS_SESSION_BUCKET)
    keys = list(bucket.objects.filter(Prefix=key_name))
    assert len(keys) == 1
    assert keys[0].key == key_name
    key = s3.Object(iris_settings.IRIS_SESSION_BUCKET, key_name).get()
    key_content = key['Body'].read().decode()
    assert json.dumps(expansion_data.TEST_JSON_1) == key_content
Ejemplo n.º 5
0
def test_bad_session(moto_boto):

    # run test
    session = IrisSessionData()
    session.store_data(expansion_data.ID1, "test")

    # check result
    with pytest.raises(IrisStorageError):
        session.get_data(expansion_data.ID1 + "x")
Ejemplo n.º 6
0
def test_missing_key(moto_boto):

    # setup
    test_content = json.dumps(expansion_data.TEST_JSON_1)

    # run test
    session = IrisSessionData()
    session.store_shared_json_data(expansion_data.ID1, test_content)

    # check result
    with pytest.raises(IrisStorageError):
        session.get_shared_json_data(expansion_data.ID1 + "x")
Ejemplo n.º 7
0
def test_missing_bucket_shared(broken_moto_boto):

    session = IrisSessionData()
    with pytest.raises(IrisStorageError):
        session.store_shared_json_data(expansion_data.SHARED_ID,
                                       expansion_data.SHARED_JSON)