Esempio n. 1
0
def test_no_sort():
    selector = ListLastComponentSelector(component_names=["no_sort"])
    sorter = NoSortListSorter(selectors=selector)
    sorted_dict = Sorter.sorted(NO_SORT, sorters=sorter)
    assert json.dumps(sorted_dict) == json.dumps(NO_SORT_RESULT)
Esempio n. 2
0
def test_list_list():
    left = [[4, 3, 1, 2], []]
    sorted_list = Sorter.sorted(left)
    assert sorted_list == [[], [1, 2, 3, 4]]
Esempio n. 3
0
def test_dict_dict():
    left = {"B": {"b": 2}, "A": {"a": 1}}
    sorted_dict = Sorter.sorted(left)
    assert sorted_dict == {"A": {"a": 1}, "B": {"b": 2}}
Esempio n. 4
0
def test_sorted_list():
    sorted_list = Sorter.sorted(TEST_LIST)
    assert json.dumps(sorted_list) == json.dumps(SORTED_LIST)
Esempio n. 5
0
def test_sorted_dict():
    sorted_dict = Sorter.sorted(TEST_DICT)
    assert json.dumps(sorted_dict) == json.dumps(SORTED_DICT)
Esempio n. 6
0
def test_json_encoder_float():
    result = Sorter.sorted(LEFT_FLOAT,
                           normalizers=FloatRoundNormalizer(places=2))
    assert result[0] == 1.12