diff options
author | Lucas Hoffmann <l-m-h@web.de> | 2017-02-03 17:33:25 +0100 |
---|---|---|
committer | Lucas Hoffmann <l-m-h@web.de> | 2017-07-17 23:44:29 +0200 |
commit | 5a11fe60dce7a71a5b98e45f8363c3651a70a2e8 (patch) | |
tree | 3ba8b6953cb5756d2c148212fe76b707399a44a5 /tests/settings | |
parent | e7812a7cbc99c810a951679ef1b61b1368a9cdf0 (diff) |
Tests for alot.settings.theme.Theme.get_attribute
Diffstat (limited to 'tests/settings')
-rw-r--r-- | tests/settings/theme_test.py | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/settings/theme_test.py b/tests/settings/theme_test.py new file mode 100644 index 00000000..abc541e3 --- /dev/null +++ b/tests/settings/theme_test.py @@ -0,0 +1,86 @@ +# Copyright (C) 2017 Lucas Hoffmann +# This file is released under the GNU GPL, version 3 or a later revision. +# For further details see the COPYING file + +from __future__ import absolute_import + +import unittest + +from alot.settings import theme + + +DUMMY_THEME = """\ +[bufferlist] + line = '', '', '', '', '', '' + line_even = '', '', '', '', '', '' + line_focus = '', '', '', '', '', '' + line_odd = '', '', '', '', '', '' +[envelope] + body = '', '', '', '', '', '' + header = '', '', '', '', '', '' + header_key = '', '', '', '', '', '' + header_value = '', '', '', '', '', '' +[global] + body = '', '', '', '', '', '' + footer = '', '', '', '', '', '' + notify_error = '', '', '', '', '', '' + notify_normal = '', '', '', '', '', '' + prompt = '', '', '', '', '', '' + tag = '', '', '', '', '', '' + tag_focus = '', '', '', '', '', '' +[help] + section = '', '', '', '', '', '' + text = '', '', '', '', '', '' + title = '', '', '', '', '', '' +[taglist] + line_even = '', '', '', '', '', '' + line_focus = '', '', '', '', '', '' + line_odd = '', '', '', '', '', '' +[search] + focus = '', '', '', '', '', '' + normal = '', '', '', '', '', '' + [[threadline]] + focus = '', '', '', '', '', '' + normal = '', '', '', '', '', '' +[thread] + arrow_bars = '', '', '', '', '', '' + arrow_heads = '', '', '', '', '', '' + attachment = '', '', '', '', '', '' + attachment_focus = '', '', '', '', '', '' + body = '', '', '', '', '', '' + header = '', '', '', '', '', '' + header_key = '', '', '', '', '', '' + header_value = '', '', '', '', '', '' + [[summary]] + even = '', '', '', '', '', '' + focus = '', '', '', '', '', '' + odd = '', '', '', '', '', '' +""" + + +class TestThemeGetAttribute(unittest.TestCase): + + @classmethod + def setUpClass(cls): + # We use a list of strings instead of a file path to pass in the config + # file. This is possible because the argument is handed to + # configobj.ConfigObj directly and that accepts eigher: + # http://configobj.rtfd.io/en/latest/configobj.html#reading-a-config-file + cls.theme = theme.Theme(DUMMY_THEME.splitlines()) + + def test_invalid_mode_raises_key_error(self): + with self.assertRaises(KeyError) as cm: + self.theme.get_attribute(0, 'mode does not exist', + 'name does not exist') + self.assertTupleEqual(cm.exception.args, ('mode does not exist',)) + + def test_invalid_name_raises_key_error(self): + with self.assertRaises(KeyError) as cm: + self.theme.get_attribute(0, 'global', 'name does not exist') + self.assertTupleEqual(cm.exception.args, ('name does not exist',)) + + # TODO tests for invalid part arguments. + + def test_invalid_colorindex_raises_value_error(self): + with self.assertRaises(ValueError): + self.theme.get_attribute(0, 'global', 'body') |