예제 #1
0
def test_list_variables(valid_adapter):
    lib = Items(default_adapter=valid_adapter)
    lib.load_work_item("workspace-id", "workitem-id-second")

    names = lib.list_work_item_variables()

    assert len(names) == 2
    assert "username" in names
    assert "address" in names
예제 #2
0
def test_delete_variables_multiple(valid_adapter):
    lib = Items(default_adapter=valid_adapter)
    lib.load_work_item("workspace-id", "workitem-id-second")

    assert "username" in lib.list_work_item_variables()
    assert len(lib.current["variables"]) == 2

    lib.delete_work_item_variables("username")

    assert "username" not in lib.list_work_item_variables()
    assert len(lib.current["variables"]) == 1
예제 #3
0
def test_delete_variables_unknown(valid_adapter):
    lib = Items(default_adapter=valid_adapter)
    lib.load_work_item("workspace-id", "workitem-id-second")

    assert len(lib.list_work_item_variables()) == 2

    lib.delete_work_item_variables("unknown-variable")
    assert len(lib.list_work_item_variables()) == 2

    with pytest.raises(KeyError):
        lib.delete_work_item_variables("unknown-variable", force=False)
    assert len(lib.list_work_item_variables()) == 2
예제 #4
0
def test_delete_variables(valid_adapter):
    lib = Items(default_adapter=valid_adapter)
    lib.load_work_item("workspace-id", "workitem-id-second")

    assert "username" in lib.list_work_item_variables()
    lib.delete_work_item_variables("username")
    assert "username" not in lib.list_work_item_variables()

    lib.delete_work_item_variables("doesntexist")

    with pytest.raises(KeyError):
        lib.delete_work_item_variables("doesntexist", force=False)
예제 #5
0
def test_delete_variables_multiple(valid_adapter):
    lib = Items(default_adapter=valid_adapter)
    lib.load_work_item("workspace-id", "workitem-id-second")

    names = lib.list_work_item_variables()
    assert "username" in names
    assert "address" in names
    assert len(names) == 2

    lib.delete_work_item_variables("username", "address")

    names = lib.list_work_item_variables()
    assert "username" not in names
    assert "username" not in names
    assert len(names) == 0
예제 #6
0
def test_keyword_save_item(valid_adapter):
    lib = Items(default_adapter=valid_adapter)
    item = lib.load_work_item("test-ws", "second-item")
    MockAdapter.validate(item, "username", "another")

    item.data["username"] = "******"
    lib.save_work_item()
    MockAdapter.validate(item, "username", "changed")
예제 #7
0
def test_keyword_save_work_item(valid_adapter):
    lib = Items(default_adapter=valid_adapter)
    item = lib.load_work_item("workspace-id", "workitem-id-second")
    MockAdapter.validate(item, "variables", VARIABLES_SECOND)

    modified = {"username": "******", "address": "*****@*****.**"}
    item.data["variables"] = modified

    lib.save_work_item()
    MockAdapter.validate(item, "variables", modified)
예제 #8
0
def test_keyword_load_item(valid_adapter):
    lib = Items(default_adapter=valid_adapter)

    item = lib.load_work_item("test-ws", "second-item")
    assert item.data["username"] == "another"
    assert item == lib.current
예제 #9
0
def test_keyword_load_work_item(valid_adapter):
    lib = Items(default_adapter=valid_adapter)

    item = lib.load_work_item("workspace-id", "workitem-id-second")
    assert item.data["variables"] == VARIABLES_SECOND
    assert item == lib.current