Exemple #1
0
    def test_extend_names(self):

        tc = TaxyTool()
        tc.add_taxonomy_set('1','a')
        tc.add_taxonomy_set('2','a')

        self.assertEquals(tc.get_handles('1'),{0,})
        self.assertEquals(tc.get_handles('2'),{1,})

        self.assertEquals(tc.get_names_by_handle(0),{'1', 'a',})
        self.assertEquals(tc.get_names_by_handle(1),{'2', 'a',})

        tc.extend_names_by_nick_name('1', 'c', 'e')
        tc.extend_names_by_nick_name('2', 'z', 'x')
        tc.extend_names_by_nick_name('1', 'd', 'f')

        self.assertEquals(tc.get_handles('a'),{0,1})
        self.assertEquals(tc.get_handles('z'),{1,})
        self.assertEquals(tc.get_handles('c'),{0,})

        #Test for a name that isn't in the taxonomy
        self.assertEquals(tc.get_handles('b'),{-1,})

        self.assertEquals(tc.get_names_by_handle(0),{'1', 'a', 'c', 'e', 'd', 'f',})
        self.assertEquals(tc.get_names_by_handle(1),{'2', 'a', 'z', 'x',})

        tc.extend_names_by_anyname('a', 'extend')
        self.assertEquals(tc.get_handles('extend'),{0,1,})
Exemple #2
0
    def test_extend_names(self):

        tc = TaxyTool()
        tc.add_taxonomy_set('1', 'a')
        tc.add_taxonomy_set('2', 'a')

        self.assertEquals(tc.get_handles('1'), {
            0,
        })
        self.assertEquals(tc.get_handles('2'), {
            1,
        })

        self.assertEquals(tc.get_names_by_handle(0), {
            '1',
            'a',
        })
        self.assertEquals(tc.get_names_by_handle(1), {
            '2',
            'a',
        })

        tc.extend_names_by_nick_name('1', 'c', 'e')
        tc.extend_names_by_nick_name('2', 'z', 'x')
        tc.extend_names_by_nick_name('1', 'd', 'f')

        self.assertEquals(tc.get_handles('a'), {0, 1})
        self.assertEquals(tc.get_handles('z'), {
            1,
        })
        self.assertEquals(tc.get_handles('c'), {
            0,
        })

        #Test for a name that isn't in the taxonomy
        self.assertEquals(tc.get_handles('b'), {
            -1,
        })

        self.assertEquals(tc.get_names_by_handle(0), {
            '1',
            'a',
            'c',
            'e',
            'd',
            'f',
        })
        self.assertEquals(tc.get_names_by_handle(1), {
            '2',
            'a',
            'z',
            'x',
        })

        tc.extend_names_by_anyname('a', 'extend')
        self.assertEquals(tc.get_handles('extend'), {
            0,
            1,
        })
Exemple #3
0
    def test_yamlize(self):

        tc = TaxyTool()
        tc.add_taxonomy_set('1', 'a')
        tc.add_taxonomy_set('2', 'b')

        tc.extend_names_by_nick_name('1', 'x')
        tc.extend_names_by_anyname('a', 'z')
        tc.extend_names_by_anyname('b', 'c')

        s = tc.dump()

        tc2 = TaxyTool.load(s)

        #@todo - a list is not a set and the yaml dump/ion serialization can not handle sets...
        self.assertEquals(tc2._cnt, 1)
        self.assertEquals(tc2.get_names_by_handle(0), {
            '1',
            'x',
            'a',
            'z',
        })
        self.assertEquals(tc2.get_names_by_handle(1), {
            '2',
            'b',
            'c',
        })

        self.assertEquals(tc._cnt, 1)
        self.assertEquals(tc.get_names_by_handle(0), {
            '1',
            'x',
            'a',
            'z',
        })
        self.assertEquals(tc.get_names_by_handle(1), {
            '2',
            'b',
            'c',
        })
Exemple #4
0
    def test_yamlize(self):

        tc = TaxyTool()
        tc.add_taxonomy_set('1','a')
        tc.add_taxonomy_set('2','b')

        tc.extend_names_by_nick_name('1','x')
        tc.extend_names_by_anyname('a','z')
        tc.extend_names_by_anyname('b','c')

        s = tc.dump()

        tc2 = TaxyTool.load(s)

        #@todo - a list is not a set and the yaml dump/ion serialization can not handle sets...
        self.assertEquals(tc2._cnt,1)
        self.assertEquals(tc2.get_names_by_handle(0),{'1','x','a','z',})
        self.assertEquals(tc2.get_names_by_handle(1),{'2','b','c',})

        self.assertEquals(tc._cnt,1)
        self.assertEquals(tc.get_names_by_handle(0),{'1','x','a','z',})
        self.assertEquals(tc.get_names_by_handle(1),{'2','b','c',})