Exemplo n.º 1
0
def test_get_taskmanager_not_exists(datasource):  # noqa: F811
    """This should error out"""
    with pytest.raises((KeyError, NoResultFound)):
        datasource.get_taskmanager(taskmanager_name="no_such_task_manager")
    with pytest.raises((KeyError, NoResultFound)):
        datasource.get_taskmanager(
            taskmanager_name="no_such_task_manager",
            taskmanager_id="11111111-1111-1111-1111-111111111111",
        )
Exemplo n.º 2
0
def test_delete_data_older_than_arg(datasource):  # noqa: F811
    """Can we delete old entries"""
    with pytest.raises((ValueError, NoResultFound), match="Argument has to be positive, non zero integer"):
        datasource.delete_data_older_than(0)
    with pytest.raises((ValueError, NoResultFound), match="Argument has to be positive, non zero integer"):
        datasource.delete_data_older_than(-5)

    # verify our old record is loaded
    result1 = datasource.get_taskmanager(taskmanager_name="taskmanager1")
    assert result1["name"] == "taskmanager1"

    # should test it deletes the old one
    datasource.delete_data_older_than(10)
    with pytest.raises((KeyError, NoResultFound)):
        datasource.get_taskmanager(taskmanager_name="taskmanager1")
Exemplo n.º 3
0
def test_get_taskmanager_exists(datasource):  # noqa: F811
    """Can I get a taskmanager by name or name and uuid"""
    # should return the 'newest' instance
    result1 = datasource.get_taskmanager(taskmanager_name="taskmanager1")
    assert result1["name"] == "taskmanager1"
    assert str(result1["taskmanager_id"]) == "11111111-1111-1111-1111-111111111111"

    result2 = datasource.get_taskmanager(
        taskmanager_name="taskmanager1",
        taskmanager_id="11111111-1111-1111-1111-111111111111",
    )
    assert result2["name"] == "taskmanager1"
    assert str(result2["taskmanager_id"]) == "11111111-1111-1111-1111-111111111111"

    assert result1 == result2
Exemplo n.º 4
0
def test_get_datablock(datasource):  # noqa: F811
    tm = datasource.get_taskmanager(taskmanager_name="taskmanager1")
    gen_id = datasource.get_last_generation_id(taskmanager_name="taskmanager1")
    result1 = datasource.get_datablock(tm["sequence_id"], gen_id)

    assert result1 == {
        "my_test_key": b"my_test_value",
        "a_test_key": b"a_test_value"
    }