コード例 #1
0
def test_remove_extension():
    exp = experiments.Experiment.copy()
    set_extension(exp, {"name": "myext", "somekey": "blah"})

    assert get_extension(exp, "myext") is not None
    remove_extension(exp, "myext")
    assert get_extension(exp, "myext") is None
コード例 #2
0
def test_get_extension():
    exp = experiments.Experiment.copy()
    set_extension(exp, {"name": "myext", "somekey": "blah"})

    ext = get_extension(exp, "myext")
    assert ext is not None
    assert ext["somekey"] == "blah"
コード例 #3
0
def test_merge_extension():
    exp = experiments.Experiment.copy()
    set_extension(exp, {"name": "myext", "somekey": "blah"})

    ext = get_extension(exp, "myext")
    assert ext is not None
    assert ext["somekey"] == "blah"

    merge_extension(exp, {
        "name": "myext",
        "somekey": "burp",
        "otherkey": "oneday"
    })

    ext = get_extension(exp, "myext")
    assert ext is not None
    assert ext["somekey"] == "burp"
    assert ext["otherkey"] == "oneday"
コード例 #4
0
def test_get_extension_returns_nothing_when_missing():
    ext = experiments.Experiment.copy()
    set_extension(ext, {"name": "myotherext", "somekey": "blah"})
    assert get_extension(ext, "myext") is None
コード例 #5
0
def test_extensions_must_have_name():
    with pytest.raises(InvalidExperiment):
        exp = experiments.Experiment.copy()
        set_extension(exp, {"somekey": "blah"})
        validate_extensions(exp)