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)
def test_list_list(): left = [[4, 3, 1, 2], []] sorted_list = Sorter.sorted(left) assert sorted_list == [[], [1, 2, 3, 4]]
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}}
def test_sorted_list(): sorted_list = Sorter.sorted(TEST_LIST) assert json.dumps(sorted_list) == json.dumps(SORTED_LIST)
def test_sorted_dict(): sorted_dict = Sorter.sorted(TEST_DICT) assert json.dumps(sorted_dict) == json.dumps(SORTED_DICT)
def test_json_encoder_float(): result = Sorter.sorted(LEFT_FLOAT, normalizers=FloatRoundNormalizer(places=2)) assert result[0] == 1.12