Exemple #1
0
 def test_other(self):
     """
     Other values are considered to have no children.
     """
     self.assertThat(get_children({}, None), Equals([]))
     self.assertThat(get_children({}, 42), Equals([]))
     self.assertThat(get_children({}, u'hello'), Equals([]))
Exemple #2
0
 def test_task_action(self):
     """
     The root message is the only child of a `Task`.
     """
     node = next(tasks_from_iterable([action_task]))
     self.assertThat(get_children(set(), node), Equals([node.root()]))
     node = next(tasks_from_iterable([message_task]))
     self.assertThat(get_children(set(), node), Equals([node.root()]))
Exemple #3
0
 def test_written_action_no_end(self):
     """
     If the `WrittenAction` has no end message, it is excluded.
     """
     node = next(tasks_from_iterable([action_task,
                                      nested_action_task])).root()
     self.assertThat(list(get_children({u'foo'}, node))[4:], Equals([]))
Exemple #4
0
 def test_written_action_no_children(self):
     """
     The children of a `WrittenAction` does not contain any child
     actions/messages if there aren't any.
     """
     node = next(tasks_from_iterable([action_task])).root()
     self.assertThat(list(get_children({u'foo'}, node)), HasLength(2))
Exemple #5
0
 def test_written_message(self):
     """
     The fields of `WrittenMessage`\\s are their children. Fields can also be
     ignored.
     """
     node = WrittenMessage.from_dict({u'a': 1, u'b': 2, u'c': 3})
     self.assertThat(get_children({u'c'}, node),
                     Equals([(u'a', 1), (u'b', 2)]))
Exemple #6
0
 def test_tuple_list(self):
     """
     The indexed items of lists are their children.
     """
     node = (u'key', [u'a', u'b', u'c'])
     self.assertThat(
         # The ignores intentionally do nothing.
         get_children({2, u'c'}, node),
         After(list, Equals([(0, u'a'), (1, u'b'), (2, u'c')])))
Exemple #7
0
 def test_tuple_dict(self):
     """
     The key/value pairs of dicts are their children.
     """
     node = (u'key', {u'a': 1, u'b': 2, u'c': 3})
     self.assertThat(
         # The ignores intentionally do nothing.
         get_children({u'c'}, node),
         Equals([(u'a', 1), (u'b', 2), (u'c', 3)]))
Exemple #8
0
 def test_written_action_end(self):
     """
     The last child of a `WrittenAction` is the end message.
     """
     node = next(
         tasks_from_iterable(
             [action_task, nested_action_task, action_task_end])).root()
     self.assertThat(
         list(get_children({u'foo'}, node))[3:], Equals([node.end_message]))
Exemple #9
0
 def test_written_action_children(self):
     """
     The children of a `WrittenAction` contain child actions/messages.
     """
     node = next(
         tasks_from_iterable(
             [action_task, nested_action_task, action_task_end])).root()
     self.assertThat(
         list(get_children({u'foo'}, node))[2], Equals(node.children[0]))
Exemple #10
0
 def test_written_action_ignored_fields(self):
     """
     Action fields can be ignored.
     """
     task = dict(action_task)
     task.update({u'c': u'3'})
     node = next(tasks_from_iterable([task])).root()
     start_message = node.start_message
     self.assertThat(
         list(get_children({u'c'}, node)),
         Equals([(u'action_status', start_message.contents.action_status),
                 (u'action_type', start_message.contents.action_type)]))
Exemple #11
0
 def test_written_action_start(self):
     """
     The children of a `WrittenAction` begin with the fields of the start
     message.
     """
     node = next(
         tasks_from_iterable(
             [action_task, nested_action_task, action_task_end])).root()
     start_message = node.start_message
     self.assertThat(
         list(get_children({u'foo'}, node))[:2],
         Equals([(u'action_status', start_message.contents.action_status),
                 (u'action_type', start_message.contents.action_type)]))