def test_notify(self): handler = turtle.Turtle() self.obs.attach(['a', 'b'], handler) self.obs.notify('a') assert_equal(len(handler.handler.calls), 1) self.obs.notify('b') assert_equal(len(handler.handler.calls), 2)
def test__eq__(self): other_graph = turtle.Turtle( graph=self.graph, action_map=self.action_map) assert_equal(self.action_graph, other_graph) other_graph.graph = None assert not self.action_graph == other_graph
def test_start_node_error(self): def raise_error(c): raise node.Error("The error") self.action_run.node = turtle.Turtle(submit_command=raise_error) self.action_run.machine.transition('ready') assert not self.action_run.start() assert_equal(self.action_run.exit_status, -2) assert self.action_run.is_failed
def setup_graph(self): self.action_names = [ 'base_one', 'base_two', 'dep_one', 'dep_one_one', 'dep_multi'] am = self.action_map = dict( (name, turtle.Turtle(name=name)) for name in self.action_names) am['dep_multi'].required_actions = [am['dep_one_one'], am['base_two']] am['dep_one_one'].required_actions = [am['dep_one']] am['dep_one'].required_actions = [am['base_one']] self.graph = [am['base_one'], am['base_two']] self.action_graph = actiongraph.ActionGraph(self.graph, am)
class DummyTestCase(TestCase): @setup def fixture(self): pass turtle_method = turtle.Turtle() def instance(self): pass @staticmethod def static(): pass
def test_from_config(self): config = dict( (name, turtle.Turtle(name=name, node='first', requires=[])) for name in self.action_names) config['dep_multi'].requires = ['dep_one_one', 'base_two'] config['dep_one_one'].requires = ['dep_one'] config['dep_one'].requires = ['base_one'] built_graph = actiongraph.ActionGraph.from_config(config) am = built_graph.action_map graph_base_names = set(a.name for a in built_graph.graph) assert_equal(graph_base_names, set(a.name for a in self.graph)) assert_equal(graph_base_names, set(['base_one', 'base_two'])) assert_equal( set(am['dep_multi'].required_actions), set([am['dep_one_one'], am['base_two']]) ) assert_equal(set(am.keys()), set(self.action_names)) assert_equal(am['base_one'].dependent_actions, [am['dep_one']]) assert_equal(am['dep_one'].dependent_actions, [am['dep_one_one']])
def test__ne__(self): other = turtle.Turtle(base='one/two', parts=['three']) assert_not_equal(self.path, other)