def test_repr_childen(self): """ Representation of a task node with children. """ node = _TaskNode(task=None, name=u'foo') node.add_child(_TaskNode(task=action_task)) self.assertThat( repr(node), Equals('<_TaskNode root foo children=1>'))
def test_repr_childen(self): """ Representation of a task node with children. """ node = _TaskNode(task=action_task, name=u'foo') node.add_child(_TaskNode(task=message_task)) self.assertThat( repr(node), Equals("<_TaskNode 'f3a32bb3-ea6b-457c-aa99-08a3d0491ab4' " "'foo' children=1>"))
def test_repr_childen(self): """ Representation of a task node with children. """ node = _TaskNode(task=action_task, name=u'foo') node.add_child(_TaskNode(task=message_task)) self.assertThat( repr(node), Equals('<_TaskNode f3a32bb3-ea6b-457c-aa99-08a3d0491ab4 ' 'foo children=1>'))
def test_first_child(self): """ ``_TaskNode.first_child`` returns the first child node that was added. """ node = _TaskNode(task=None, name=u'foo') child = _TaskNode(task=action_task) child2 = _TaskNode(task=action_task_end) node.add_child(child2) node.add_child(child) self.assertThat( node.first_child(), Equals(child2))
def test_children(self): """ ``_TaskNode.children`` returns an list of child nodes sorted by their level regardless of the order they were added. """ node = _TaskNode(task=action_task, name=u'foo') child = _TaskNode(task=nested_action_task) child2 = _TaskNode(task=action_task_end) node.add_child(child2) node.add_child(child) self.assertThat( node.children(), Equals([child, child2]))
def test_children(self): """ ``_TaskNode.children`` returns an list of child nodes sorted by their level regardless of the order they were added. """ node = _TaskNode(task=action_task, name=u'foo') child = _TaskNode(task=nested_action_task) child2 = _TaskNode(task=action_task_end) node.add_child(child2) node.add_child(child) self.assertThat( node.children(), Equals([child, child2]))
def test_nested_children(self): """ ``_TaskNode.children`` does not include grandchildren. """ node = _TaskNode(task=action_task, name=u'foo') child = _TaskNode(task=message_task) node.add_child(child) child2 = _TaskNode(task=nested_action_task) node.add_child(child2) self.assertThat( node.children(), Equals([child])) self.assertThat( child.children(), Equals([child2]))
def test_nested_children(self): """ ``_TaskNode.children`` does not include grandchildren. """ node = _TaskNode(task=action_task, name=u'foo') child = _TaskNode(task=message_task) node.add_child(child) child2 = _TaskNode(task=nested_action_task) node.add_child(child2) self.assertThat( node.children(), Equals([child])) self.assertThat( child.children(), Equals([child2]))
def test_none(self): """ Passing ``None`` as the task value raises ``ValueError`` """ self.assertThat( lambda: _TaskNode(task=None), raises(ValueError))
def test_none(self): """ Passing ``None`` as the task value raises ``ValueError`` """ self.assertThat( lambda: _TaskNode(task=None), raises(ValueError))
def test_repr_root(self): """ Representation of a root node. """ node = _TaskNode(task=None, name=u'foo') self.assertThat( repr(node), Equals('<_TaskNode root foo children=0>'))
def test_no_children(self): """ ``_TaskNode.children`` returns an empty list for a node with no children. """ node = _TaskNode(task=action_task, name=u'foo') self.assertThat( node.children(), Equals([]))
def test_repr(self): """ Representation of a task node. """ node = _TaskNode(task=action_task) self.assertThat( repr(node), Equals('<_TaskNode f3a32bb3-ea6b-457c-aa99-08a3d0491ab4 ' 'app:action@1/started children=0>'))
def test_no_children(self): """ ``_TaskNode.children`` returns an empty list for a node with no children. """ node = _TaskNode(task=action_task, name=u'foo') self.assertThat( node.children(), Equals([]))
def test_repr_nameless(self): """ Representation of a task without a name. """ node = _TaskNode(task=unnamed_message) self.assertThat( repr(node), Equals("<_TaskNode 'cdeb220d-7605-4d5f-8341-1a170222e308' " "'<UNNAMED TASK>' children=0>"))
def test_repr(self): """ Representation of a task node. """ node = _TaskNode(task=action_task) self.assertThat( repr(node), Equals("<_TaskNode 'f3a32bb3-ea6b-457c-aa99-08a3d0491ab4' " "'app:action@1/started' children=0>"))
def test_repr_nameless(self): """ Representation of a task without a name. """ node = _TaskNode(task=unnamed_message) self.assertThat( repr(node), Equals("<_TaskNode 'cdeb220d-7605-4d5f-8341-1a170222e308' " "'<UNNAMED TASK>' children=0>"))
def test_repr_nameless(self): """ Representation of a task without a name. """ node = _TaskNode(task=unnamed_message) self.assertThat( repr(node), Equals('<_TaskNode cdeb220d-7605-4d5f-8341-1a170222e308 ' '{} children=0>'.format(_TaskNode._DEFAULT_TASK_NAME)))