예제 #1
0
def test_update_bad(dataspace):  # noqa: F811
    """Do updates fail to work as expected"""
    metadata_row = dataspace.get_metadata(
        taskmanager_id=1,
        generation_id=1,
        key="my_test_key",
    )
    header_row = dataspace.get_header(
        taskmanager_id=1,
        generation_id=1,
        key="my_test_key",
    )
    with pytest.raises((KeyError, NoResultFound)):
        dataspace.update(
            taskmanager_id=100,
            generation_id=1,
            key="my_test_key",
            value=b"I changed IT",
            header=Header(
                header_row[0],
                create_time=header_row[4],
                expiration_time=header_row[5],
                scheduled_create_time=header_row[6],
                creator=header_row[7],
                schema_id=header_row[8],
            ),
            metadata=Metadata(
                metadata_row[0],
                state=metadata_row[4],
                generation_id=metadata_row[2],
                generation_time=metadata_row[5],
                missed_update_count=metadata_row[6],
            ),
        )
예제 #2
0
def test_get_header(dataspace):  # noqa: F811
    """Can we fetch a header?"""
    result = dataspace.get_header(
        taskmanager_id=1,
        generation_id=1,
        key="my_test_key",
    )

    assert result[0] == "11111111-1111-1111-1111-111111111111"
    assert result[1] == 1
    assert result[2] == 1
    assert result[3] == "my_test_key"
    assert result[7] == "module"
예제 #3
0
def test_update(dataspace):  # noqa: F811
    """Do updates work as expected"""
    metadata_row = dataspace.get_metadata(
        taskmanager_id=1,
        generation_id=1,
        key="my_test_key",
    )
    header_row = dataspace.get_header(
        taskmanager_id=1,
        generation_id=1,
        key="my_test_key",
    )
    dataspace.update(
        taskmanager_id=1,
        generation_id=1,
        key="my_test_key",
        value=b"I changed IT",
        header=Header(
            header_row[0],
            create_time=header_row[4],
            expiration_time=header_row[5],
            scheduled_create_time=header_row[6],
            creator=header_row[7],
            schema_id=header_row[8],
        ),
        metadata=Metadata(
            metadata_row[0],
            state=metadata_row[4],
            generation_id=metadata_row[2],
            generation_time=metadata_row[5],
            missed_update_count=metadata_row[6],
        ),
    )

    result1 = dataspace.get_dataproduct(
        taskmanager_id=1,
        generation_id=1,
        key="my_test_key",
    )

    assert result1 == b"I changed IT"
예제 #4
0
def test_get_header_not_exist(dataspace):  # noqa: F811
    """Does it error out if we ask for a bogus header?"""
    with pytest.raises((KeyError, NoResultFound)):
        dataspace.get_header(
            taskmanager_id=100,
            generation_id=1,
            key="my_test_key",
        )

    with pytest.raises((KeyError, NoResultFound)):
        dataspace.get_header(
            taskmanager_id=100,
            generation_id=10,
            key="my_test_key",
        )

    with pytest.raises((KeyError, NoResultFound)):
        dataspace.get_header(
            taskmanager_id=100,
            generation_id=1,
            key="no_such_key_exists",
        )