1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# 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
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 = '', '', '', '', '', ''
[namedqueries]
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')
|