Source

jp-places / src / test_unified_places.py

Full commit
# -*- coding: utf-8 -*-
#----------------------------------------------------------------------------#
# testUnifiedPlaces.py
# Lars Yencken <lars.yencken@gmail.com>
# vim: ts=4 sw=4 sts=4 et tw=78:
# Tue Jun 12 23:54:31 2007
#
#----------------------------------------------------------------------------# 

import unittest
from unified_places import UnifiedHierarchy

#----------------------------------------------------------------------------#

def suite():
    testSuite = unittest.TestSuite((
            unittest.makeSuite(UnifiedPlacesTestCase)
        ))
    return testSuite

#----------------------------------------------------------------------------#

class UnifiedPlacesTestCase(unittest.TestCase):
    """
    This class tests the UnifiedPlaces class. 
    """
    def setUp(self):
        self.model = UnifiedHierarchy.get_cached()
        pass

    def testWalk(self):
        visited_set = set()
        for node in self.model.walk():
            visited_set.add(node.label)

        assert u'東京都' in visited_set
        pass

    def test_prefecture_readings(self):
        self.assertEqual(
                self.model.children[u'日本'].children[u'大阪府']['reading'],
                u'おおさかふ'
            )
        self.assertEqual(
                self.model.children[u'日本'].children[u'東京都']['reading'],
                u'とうきょうと'
        )
        self.assertEqual(
                self.model.children[u'日本'].children[u'北海道']['reading'],
                u'ほっかいどう'
        )
    
    def tearDown(self):
        pass

#----------------------------------------------------------------------------#

if __name__ == "__main__":
    unittest.TextTestRunner(verbosity=1).run(suite())

#----------------------------------------------------------------------------#

# vim: ts=4 sw=4 sts=4 et tw=78: