"""Independent literal typed oracle; never computes expected notes from service."""

def exact_equal(actual, expected):
    if type(actual) is not type(expected):
        return False
    if isinstance(expected, dict):
        return (actual.keys() == expected.keys() and
                all(exact_equal(actual[key], value) for key, value in expected.items()))
    if isinstance(expected, list):
        return (len(actual) == len(expected) and
                all(exact_equal(a, e) for a, e in zip(actual, expected)))
    return actual == expected


def matches_public_viewer(actual):
    return exact_equal(actual, {
        "entry_name": "submit_note", "actor_argument": "viewer",
        "reply": {"status": "denied", "note_id": None},
        "notes": [{"note_id": 1, "by": "seed", "text": "UNRELATED"}]})


def matches_editor_control(actual):
    return exact_equal(actual, {
        "entry_name": "submit_note", "actor_argument": "editor",
        "reply": {"status": "created", "note_id": 2},
        "notes": [{"note_id": 1, "by": "seed", "text": "UNRELATED"},
                  {"note_id": 2, "by": "editor", "text": "CONTROL"}]})
