"""
$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/test/utest_link_triple.py $
$Id: utest_link_triple.py 27889 2006-01-26 23:15:28Z rmasse $
"""

from dulcinea.link_triple import LinkTripleDatabase
from sancho.utest import UTest

class LinkTripleTest (UTest):

    def check_link_triple_db(self):
        self.ltdb = LinkTripleDatabase()
        assert len(self.ltdb.get_links()) == 0
        self.ltdb.set_links([('a', 'b', 'c'), ('1', '2', '3')])
        assert len(self.ltdb.get_links()) == 2
        assert self.ltdb[0] == ('a', 'b', 'c')
        self.ltdb.insert_link(('A', 'B', 'C'), 1)
        assert len(self.ltdb.get_links()) == 3
        assert self.ltdb.get_links() == [('a', 'b', 'c'),
                                         ('A', 'B', 'C'),
                                         ('1', '2', '3')]
        self.ltdb[2] = ('4', '5', '6')
        assert self.ltdb.get_links() == [('a', 'b', 'c'),
                                         ('A', 'B', 'C'),
                                         ('4', '5', '6')]
        del self.ltdb[0]
        assert self.ltdb.get_links() == [('A', 'B', 'C'),
                                         ('4', '5', '6')]

if __name__ == "__main__":
    LinkTripleTest()
