Example #1
0
def test_get_2_proposed_fixes():
    generate_fix_proposal(ds_ids[0], fixes[0])
    generate_fix_proposal(ds_ids[1], fixes[1])

    fix_processor.get_fix_prop_store = Mock(return_value=prop_store)

    proposed_fixes = fix_processor.get_proposed_fixes()

    assert len(proposed_fixes) == 2

    assert (proposed_fixes[0]) == {
        "dataset_id":
        "ds.1.1.1.1.1.1",
        "fixes": [{
            "fix": {
                "category": "test_fixes",
                "description": "Applies fix 1",
                "fix_id": "Fix1",
                "operands": {
                    "arg1": "1"
                },
                "reference_implementation": "daops.test.test_fix1",
                "title": "Apply Fix 1",
            },
            "history": [],
            "reason": "",
            "status": "proposed",
            "timestamp": now_string(),
        }],
    }

    assert proposed_fixes[1] == {
        "dataset_id":
        "ds.2.1.1.1.1.1",
        "fixes": [{
            "fix": {
                "category": "test_fixes",
                "description": "Applies fix 2",
                "fix_id": "Fix2",
                "operands": {
                    "arg2": "2"
                },
                "reference_implementation": "daops.test.test_fix2",
                "title": "Apply Fix 2",
            },
            "history": [],
            "reason": "",
            "status": "proposed",
            "timestamp": now_string(),
        }],
    }
Example #2
0
 def _get_fix_container(self, fix, status, reason=""):
     return {
         "fix": fix,
         "status": status,
         "timestamp": now_string(),
         "reason": reason,
         "history": [],
     }
Example #3
0
def test_propose():
    _id = "ds.1.1.1.1.1.1"
    store.propose(_id, fixes[0])

    r = record = store.get(_id)
    # pp.pprint(r)
    found = r["fixes"]
    assert found[0]["status"] == "proposed"
    assert found[0]["fix"] == fixes[0]
    assert found[0]["timestamp"].startswith(now_string()[:10])
    assert found[0]["history"] == []
    assert len(found) == 1
    _clear_store()
Example #4
0
def test_withdraw():
    test_publish(do_clear=False)

    _id = "ds.1.1.1.1.1.1"
    store.withdraw(_id, fixes[0], reason="bad fix")

    r = record = store.get(_id)

    found = r["fixes"]
    assert found[0]["status"] == "withdrawn"
    assert found[0]["fix"] == fixes[0]
    assert found[0]["timestamp"].startswith(now_string()[:10])

    history = found[0]["history"]
    assert len(history) == 2
    assert history[0]["status"] == "published"
    assert history[0]["reason"] == ""

    _clear_store()
Example #5
0
def test_publish(do_clear=True):
    _id = "ds.1.1.1.1.1.1"
    store.propose(_id, fixes[0])
    store.publish(_id, fixes[0])

    r = record = store.get(_id)

    found = r["fixes"]
    assert found[0]["status"] == "published"
    assert found[0]["fix"] == fixes[0]
    assert found[0]["timestamp"].startswith(now_string()[:10])

    history = found[0]["history"]
    assert len(history) == 1
    assert history[0]["status"] == "proposed"
    assert history[0]["reason"] == ""

    if do_clear:
        _clear_store()
Example #6
0
def test_reject():
    _id = "ds.1.1.1.1.1.1"
    store.propose(_id, fixes[0])
    store.reject(_id, fixes[0], reason="wrong")

    r = record = store.get(_id)

    found = r["fixes"]
    assert found[0]["status"] == "rejected"
    assert found[0]["reason"] == "wrong"

    assert found[0]["fix"] == fixes[0]
    assert found[0]["timestamp"].startswith(now_string()[:10])

    history = found[0]["history"]
    assert len(history) == 1
    assert history[0]["status"] == "proposed"
    assert history[0]["reason"] == ""

    _clear_store()
Example #7
0
def test_publish_diff_operands():
    test_publish(do_clear=False)

    _id = "ds.1.1.1.1.1.1"
    store.publish(_id, fixes[2])

    r = record = store.get(_id)

    found = r["fixes"]

    assert found[0]["status"] == "published"
    assert found[0]["fix"] == fixes[2]
    assert found[0]["timestamp"].startswith(now_string()[:10])

    history = found[0]["history"]
    assert len(history) == 2
    assert history[0]["status"] == "published"
    assert history[0]["reason"] == ""

    _clear_store()