File: test_shelf.py

package info (click to toggle)
tomoe 0.6.0-1.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 51,408 kB
  • ctags: 29,632
  • sloc: xml: 1,387,627; ansic: 11,515; sh: 9,072; ruby: 1,344; python: 762; makefile: 447
file content (58 lines) | stat: -rw-r--r-- 1,627 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
50
51
52
53
54
55
56
57
58
# encoding: utf-8
import os
import sys
import glob
import unittest
import test_common
import tomoe

class TomoeShelfTest(unittest.TestCase):

    def testRegister(self):
        dict = tomoe.Dict("XML")
        dict_name = "test-dict"

        shelf = tomoe.Shelf()
        self.assert_(not shelf.has_dict(dict_name))

        shelf.register_dict(dict_name, dict)
        self.assertEqual(dict, shelf.get_dict(dict_name))

    def testUnregister(self):
        dict = tomoe.Dict("XML")
        dict_name = "test-dict"

        shelf = tomoe.Shelf()
        self.assert_(not shelf.has_dict(dict_name))

        shelf.register_dict(dict_name, dict)
        self.assertEqual(dict, shelf.get_dict(dict_name))

        shelf.unregister_dict(dict_name)
        self.assert_(not shelf.has_dict(dict_name))

        shelf.register_dict(dict_name, dict)
        self.assertEqual(dict, shelf.get_dict(dict_name))

        dict_unihan = tomoe.Dict("Unihan")
        shelf.register_dict(dict_name, dict_unihan)
        self.assertEqual(dict_unihan, shelf.get_dict(dict_name))

        shelf.unregister_dict(dict_name)
        self.assert_(not shelf.has_dict(dict_name))

    def testGetNames(self):
        dict1 = tomoe.Dict("XML")
        dict_name1 = "test-dict1"

        dict2 = tomoe.Dict("XML")
        dict_name2 = "test-dict2"

        shelf = tomoe.Shelf()
        self.assertEqual(0, len(shelf.get_dict_names()))

        shelf.register_dict(dict_name1, dict1)
        shelf.register_dict(dict_name2, dict2)
        self.assertEqual([dict_name1, dict_name2].sort(), shelf.get_dict_names().sort())

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