#!/www/python/bin/python
"""
$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/test/test_keyed.py $
$Id: test_keyed.py 23278 2003-12-08 22:14:29Z dbinger $
"""

from sancho.unittest import TestScenario, parse_args, run_scenarios
from dulcinea.keyed import Keyed, KeyedMap

tested_modules = ["dulcinea.keyed"]

class Test (TestScenario):

    def check_a(self):
        self.test_stmt('self.map = KeyedMap()')
        self.test_stmt('self.a = Keyed()')
        self.test_val('self.a.get_key()', None)        
        self.test_stmt('self.map.add(self.a)')
        self.test_exc('self.map.add(self.a)', AssertionError)
        self.test_stmt('self.b = Keyed()')
        self.test_stmt('self.b.junk = 1')
        self.test_exc('self.map.add(self.b)', TypeError)
        self.test_exc('self.map.add(1)', TypeError)        
        self.test_val('self.a.get_key()', 1)
        self.test_val('self.map.get_mapping().items()', [(1, self.a)])
        self.test_val('self.map.get(1)', self.a)

if __name__ == "__main__":
    (scenarios, options) = parse_args()
    run_scenarios(scenarios, options)
