"""Compare independently fixed literal replies and full selected file bytes."""
def exact_equal(actual, expected):
    if type(actual) is not type(expected):
        return False
    if type(expected) is dict:
        return actual.keys() == expected.keys() and all(
            exact_equal(actual[key], value) for key, value in expected.items())
    if type(expected) is list:
        return len(actual) == len(expected) and all(
            exact_equal(a, e) for a, e in zip(actual, expected))
    return actual == expected


def TestNoPartialOutput(observation):
    return exact_equal(observation, {
        'reply': {'status': 'cancelled', 'published_bytes': 0},
        'files': {'target.bin': '4b454550', 'unrelated.bin': '4f54484552'}})


def TestNormalCompletion(observation):
    return exact_equal(observation, {
        'reply': {'status': 'completed', 'published_bytes': 2},
        'files': {'target.bin': '4142', 'unrelated.bin': '4f54484552'}})
