File: test_config.py

package info (click to toggle)
tomoe 0.6.0-1.3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 51,396 kB
  • sloc: xml: 1,387,526; ansic: 11,515; sh: 9,072; ruby: 1,344; python: 762; makefile: 450
file content (49 lines) | stat: -rw-r--r-- 1,290 bytes parent folder | download | duplicates (2)
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
# encoding: utf-8
import os
import sys
import glob
import unittest
import test_common
import tomoe

class TomoeConfigTest(unittest.TestCase):

    def setUp(self):
        self.config_filename = "test-config"
        config_file = open(self.config_filename, "w")
        contents = """
[config]
use-system-dictionaries = false
user-dictionary = user-dict
languages = ja;zh_CN

[test1-dictionary]
type = xml
file = ../../data/kanjidic2.xml

[test2-dictionary]
type = xml
file = ../../data/kanjidic2.xml
         """
        config_file.write(contents)
        config_file.close()
        self.config = tomoe.Config(self.config_filename)

    def tearDown(self):
        if os.access(self.config_filename, os.F_OK):
            os.unlink(self.config_filename)
        
    def testGetFilename(self):
        self.assertEqual(self.config_filename, self.config.get_filename())

    def testGetUserDictName(self):
        self.assertEqual('user-dict', self.config.get_user_dict_name())

    def testGetLanguages(self):
        self.assertEqual(sorted(['ja', 'zh_CN']), sorted(self.config.get_languages()))

    def testMakeShelf(self):
        shelf = self.config.make_shelf('')
        self.assertEqual(sorted(['test1', 'test2']), sorted(shelf.get_dict_names()))

# vi:ts=4:nowrap:ai:expandtab