1#
2# Gramps - a GTK+/GNOME based genealogy program
3#
4# Copyright (C) 2007 Donald N. Allingham
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19#
20
21""" Unittest for testing ... """
22
23import unittest
24
25from ..keyword import (KEYWORDS, get_translation_from_keyword,
26                       get_keyword_from_translation)
27
28class TestCase(unittest.TestCase):
29
30    def keyword_case(self, item1, item2):
31        result = get_translation_from_keyword(item1)
32        self.assertEqual(result, item2)
33
34    def translation_case(self, item1, item2):
35        result = get_keyword_from_translation(item1)
36        self.assertEqual(result, item2)
37
38    def test_from_keyword(self):
39        for keyword, code, standard, upper in KEYWORDS:
40            self.keyword_case(keyword, standard)
41
42    def test_from_translation(self):
43        for keyword, code, standard, upper in KEYWORDS:
44            self.translation_case(standard, keyword)
45
46    def test_from_lower(self):
47        for keyword, code, standard, upper in KEYWORDS:
48            self.translation_case(standard.lower(), keyword)
49
50    def test_from_upper(self):
51        for keyword, code, standard, upper in KEYWORDS:
52            self.translation_case(upper, keyword.upper())
53
54
55if __name__ == "__main__":
56    unittest.main()
57