def test_get_or_create_context(self): root = Context('root') self.assert_(root.get_or_create_context('root') is root) child = root.get_or_create_context('child') self.assert_(root.get_or_create_context('child') is child) self.assert_(child.get_or_create_context('child') is child)
def test_add_and_remove_endpoint(self): context = Context('c') endpoint = EndpointMockup('endpoint') context.add_endpoint(endpoint) self.assert_(endpoint in context.get_endpoints()) self.assert_(endpoint.get_context() is context) context.remove_endpoint(endpoint) self.assert_(not endpoint in context.get_endpoints()) self.assert_(endpoint.get_context() is None)
def test_get_name(self): context = Context('root') self.assert_(context.get_name() == 'root')
def test_get_parent(self): root = Context('root') child = Context('child', root) self.assert_(child.get_parent() is root) self.assert_(root.get_parent() is None)
def test_get_child_contexts(self): root = Context('root') child = root.get_or_create_context('child1') self.assert_(child.get_parent() is root) self.assert_(child in root.get_child_contexts())