diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2017-01-26 15:23:00 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2017-01-27 10:34:45 -0800 |
commit | 7fd9b50a7f43821c6931e4f19efc37c138d77837 (patch) | |
tree | b488aa6cdd69d1fa1edd84a0c93a8fca8e55a66f /tests/widgets | |
parent | 9d0a67842e5a9c85f08d619d60360cb90255b6a5 (diff) |
tests/widgets/globals: Add test for sorting of TagWidgets
Diffstat (limited to 'tests/widgets')
-rw-r--r-- | tests/widgets/__init__.py | 0 | ||||
-rw-r--r-- | tests/widgets/globals_test.py | 40 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/widgets/__init__.py b/tests/widgets/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/widgets/__init__.py diff --git a/tests/widgets/globals_test.py b/tests/widgets/globals_test.py new file mode 100644 index 00000000..4974062e --- /dev/null +++ b/tests/widgets/globals_test.py @@ -0,0 +1,40 @@ +# encoding=utf-8 +# Copyright © 2017 Dylan Baker + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +"""Tests for the alot.widgets.globals module.""" + +from __future__ import absolute_import + +import unittest + +import mock + +from alot.widgets import globals as globals_ + + +class TestTagWidget(unittest.TestCase): + + def test_sort(self): + """Test sorting.""" + from alot.helper import tag_cmp + with mock.patch( + 'alot.widgets.globals.settings.get_tagstring_representation', + lambda t, _, __: {'translated': t, 'normal': None, + 'focussed': None}): + expected = ['a', 'z', 'aa', 'bar', 'foo'] + base = [globals_.TagWidget(x) for x in expected] + actual = list(sorted(base, cmp=tag_cmp, key=lambda x: x.translated)) + self.assertListEqual([g.translated for g in actual], expected) |