def check(self, container): container = core.SerialContainer() container.add(stages.CurrentState("1")) container.add(stages.CurrentState("2")) container.add(stages.CurrentState("3")) with self.assertRaises(IndexError): container["unknown"] child = container["2"] self.assertEqual(child.name, "2") self.assertEqual([child.name for child in container], ["1", "2", "3"])
def test(self): task = core.Task() self.assertEqual(task.id, "") task = core.Task("foo", core.SerialContainer()) self.assertEqual(task.id, "foo") task = core.Task("task") self.assertEqual(task.id, "task") current = stages.CurrentState("current") self.assertEqual(current.name, "current") current.timeout = 1.23 self.assertEqual(current.timeout, 1.23) task.add(current) # ownership of current was passed to task with self.assertRaises(TypeError): current.name task.add(stages.Connect("connect", [])) task.add(stages.FixedState())
def test_serial(self): self.check(core.SerialContainer())
def test_move(self): container = core.SerialContainer() stage = stages.CurrentState() container.add(stage) with self.assertRaises(TypeError): stage.name