def test_init_col_group(self): headers = ["a1", "a2"] desc = [ { "name": "a1" }, { "group": { "namespace": "g2", "columns": [{ "name": "a2" }] } }, ] kvgl = KeyValueGroupList(headers, None, desc) assert kvgl.default_cfg == expected() assert kvgl.headerindexmap == {'a1': 0, 'a2': 1} assert len(kvgl.output_configs) == 2 assert kvgl.output_configs[0].namespace == "g2" assert kvgl.output_configs[0].columns == [(expected(name="a2"), 1)] # Default group always comes last assert kvgl.output_configs[1].namespace == "" assert kvgl.output_configs[1].columns == [(expected(name="a1"), 0)]
def test_init_col_group_multi(self): headers = ["a1", "a2", "a3", "a4", "a5"] desc = [ {"name": "a1"}, {"group": {"namespace": "g2", "columns": [{"name": "a2"}]}}, {"name": "a3"}, {"group": { "namespace": "g4", "columns": [{"name": "a4"}, {"name": "a5"}] }}, ] kvgl = KeyValueGroupList(headers, None, desc) assert kvgl.default_cfg == expected() assert kvgl.headerindexmap == { 'a1': 0, 'a2': 1, 'a3': 2, 'a4': 3, 'a5': 4} assert len(kvgl.output_configs) == 3 assert kvgl.output_configs[0].namespace == "g2" assert kvgl.output_configs[0].columns == [(expected(name="a2"), 1)] assert kvgl.output_configs[1].namespace == "g4" assert kvgl.output_configs[1].columns == [ (expected(name="a4"), 3), (expected(name="a5"), 4)] # Default group always comes last assert kvgl.output_configs[2].namespace == "" assert kvgl.output_configs[2].columns == [ (expected(name="a1"), 0), (expected(name="a3"), 2)]
def test_init_col(self): headers = ["a1"] kvgl = KeyValueGroupList( headers, None, [{"name": "a1", "visible": False}]) assert kvgl.default_cfg == expected() assert kvgl.headerindexmap == {'a1': 0} assert len(kvgl.output_configs) == 1 assert kvgl.output_configs[0].namespace == "" configs = kvgl.output_configs[0].columns assert configs[0] == (expected(name="a1", visible=False), 0)
def test_init_col_unincluded(self): headers = ["a2", "a1"] kvgl = KeyValueGroupList(headers, { "include": False, "includeclient": False}, [{"name": "a2", "include": True}]) assert kvgl.default_cfg == expected(include=False, includeclient=False) assert len(kvgl.output_configs) == 1 assert kvgl.output_configs[0].namespace == "" configs = kvgl.output_configs[0].columns assert len(configs) == 1 assert configs[0] == (expected( name="a2", include=True, includeclient=False), 0)
def test_init_col_ordered_unordered(self): headers = ["a2", "a1"] kvgl = KeyValueGroupList(headers, None, [ {"name": "a2", "visible": False}, {"name": "a1", "position": 1}]) assert kvgl.default_cfg == expected() assert len(kvgl.output_configs) == 1 assert kvgl.output_configs[0].namespace == "" configs = kvgl.output_configs[0].columns assert len(configs) == 2 assert configs[0] == (expected(name="a1", position=1), 1) assert configs[1] == (expected(name="a2", visible=False), 0)
def test_init_col_complicated_order(self): headers, column_cfgs = self.get_complicated_headers() kvgl = KeyValueGroupList(headers, None, column_cfgs) assert kvgl.default_cfg == expected() assert len(kvgl.output_configs) == 1 assert kvgl.output_configs[0].namespace == "" configs = kvgl.output_configs[0].columns assert len(configs) == 6 assert configs[0] == (expected(name="a1", position=1, split="|"), 3) assert configs[1] == (expected(name="a2", visible=False), 1) assert configs[2] == (expected(name="a3"), 0) assert configs[3] == (expected( name="a4", position=4, clientvalue="*-{{ value }}-*"), 2) assert configs[4] == (expected(name="a5"), 5) assert configs[5] == (expected(name="a6"), 6)