Exemplo n.º 1
0
def test_order_json_sorts_list():
    l = list(range(10))
    random.shuffle(l)
    data = {'a': l}
    gold_data = {'a': list(range(10))}
    res = order_json(data)
    assert res == gold_data
Exemplo n.º 2
0
def hash_outputs(outputs: Dict[str, Union[str, List[str]]]) -> str:
    """Hash the outputs of a task.

    :param outputs: The list of output files to hash.
    :returns: The hash of the outputs.
    """
    LOGGER.debug("Hashing %s", outputs)
    output_hashes = {k: hash_files(listify(v)) for k, v in outputs.items()}
    LOGGER.debug(output_hashes)
    out_hash = sha1(json.dumps(
        order_json(output_hashes)).encode('utf-8')).hexdigest()
    LOGGER.debug("Output hash: %s", out_hash)
    return out_hash
Exemplo n.º 3
0
def test_sorts_subdict():
    gold = [random.random() in range(random.randint(5, 10))]
    gold_dict = {
        random.randint(0, 100): random.random()
        for _ in range(random.randint(10, 20))
    }
    index = random.randint(0, len(gold) - 1)
    gold[index] = gold_dict

    mixed = deepcopy(gold)
    mixed[index] = shuffle_dict(mixed[index])
    data = {'a': mixed}
    res = order_json(data)
    assert res['a'] == gold
Exemplo n.º 4
0
def test_order_json_doesnt_sorts_list():
    gold = list(range(10))
    random.shuffle(gold)
    data = {'a': gold}
    res = order_json(data)
    assert res['a'] == gold
Exemplo n.º 5
0
def test_order_json_e2e(data, mixed):
    res = order_json(mixed)
    assert res == data
Exemplo n.º 6
0
def test_order_json_doesnt_sorts_list():
    gold = list(range(10))
    random.shuffle(gold)
    data = {'a': gold}
    res = order_json(data)
    assert res['a'] == gold
Exemplo n.º 7
0
def test_order_json_e2e(data, mixed):
    res = order_json(mixed)
    assert res == data