def test_unknown_name_no_window_class(self): mappings = base_mappings() args = AttrDict(base_config()) mi3 = MockI3(MockWorkspace(1, MockLeaf("giregox", "", "", ""))) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ["1: ?"] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)
def test_long_unknown_name_ignore(self): mappings = base_mappings() args = AttrDict(base_config()) args.ignore_unknown = True mi3 = MockI3(MockWorkspace(1, MockLeaf("giregox-giregox-giregox"))) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ["1: "] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)
def test_long_unknown_name_no_match_icon(self): mappings = base_mappings() mappings["_no_match"] = "question" args = AttrDict(base_config()) mi3 = MockI3(MockWorkspace(1, MockLeaf("giregox-giregox-giregox"))) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ["1: \uf128giregox-gire…"] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)
def test_two_apps_same(self): mappings = base_mappings() args = AttrDict(base_config()) mi3 = MockI3(MockWorkspace(1, MockLeaf("firefox"), MockLeaf("firefox"))) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ["1: \uf269|\uf269"] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)
def test_pango(self): mappings = base_mappings() mappings["emacs"] = '<span font_desc="file-icons">\ue926</span>' args = AttrDict(base_config()) mi3 = MockI3(MockWorkspace(1, MockLeaf("emacs")), ) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ['1: <span font_desc=\\"file-icons\\">\ue926</span>'] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)
def test_simple(self): mappings = base_mappings() args = AttrDict(base_config()) mi3 = MockI3( MockWorkspace(1, MockLeaf("firefox")), MockWorkspace(2, MockLeaf("chromium-browser")), ) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ["1: \uf269", "2: \uf268"] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)
def test_two_apps_one_ws_delim(self): mappings = base_mappings() args = AttrDict(base_config()) args.delimiter = " " mi3 = MockI3( MockWorkspace(1, MockLeaf("firefox"), MockLeaf("chromium-browser"))) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ["1: \uf269 \uf268"] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)
def test_transform_title_replace_all(self): mappings = base_mappings() mappings["emacs"] = { "transform_title": { "from": r"(.*)", "to": r"replaced", }, } args = AttrDict(base_config()) mi3 = MockI3(MockWorkspace(1, MockLeaf("emacs", "foo [bar] baz"))) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ["1: replaced"] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)
def test_transform_title_icon(self): mappings = base_mappings() mappings["emacs"] = { "transform_title": { "from": r".*\[(.+?)\].*", "to": r"\1", }, "icon": "play", } args = AttrDict(base_config()) mi3 = MockI3(MockWorkspace(1, MockLeaf("emacs", "foo [bar] baz"))) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ["1: \uf04bbar"] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)
def test_transform_title_compress(self): mappings = base_mappings() mappings["emacs"] = { "transform_title": { "from": r".*\[(.+?)\].*", "to": r"\1", "compress": True } } args = AttrDict(base_config()) mi3 = MockI3( MockWorkspace( 1, MockLeaf("emacs", "project [a very-too_long+window title]"))) rename = build_rename(mi3, mappings, args) rename(mi3, None) expected = ["1: a ver-too_lo…"] actual = get_names(mi3.cmd) self.assertListEqual(expected, actual)