示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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)
示例#9
0
    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)
示例#10
0
    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)