コード例 #1
0
ファイル: test_tree.py プロジェクト: itamarst/eliottree
 def test_merge_tasks_no_matches(self):
     """
     Merging tasks when no tasks match returns an empty set of tasks.
     """
     tree = Tree()
     matches = tree.merge_tasks(
         [action_task, message_task], [lambda task: False])
     self.expectThat(list(matches), Equals([]))
コード例 #2
0
ファイル: test_tree.py プロジェクト: x0zzz/eliottree
 def test_merge_tasks_no_matches(self):
     """
     Merging tasks when no tasks match returns an empty set of tasks.
     """
     tree = Tree()
     matches = tree.merge_tasks(
         [action_task, message_task], [lambda task: False])
     self.expectThat(list(matches), Equals([]))
コード例 #3
0
ファイル: test_tree.py プロジェクト: mithrandi/eliottree
 def test_merge_startless_tasks(self):
     """
     Merging a task that will never have a start parent raises
     ``RuntimeError``.
     """
     tree = Tree()
     self.assertThat(
         lambda: tree.merge_tasks([action_task_end]),
         raises(RuntimeError))
コード例 #4
0
ファイル: test_tree.py プロジェクト: x0zzz/eliottree
 def test_merge_nested_tasks(self):
     """
     Merge nested tasks into the tree and retrieve an list of key-node
     pairs ordered by task timestamp.
     """
     tree = Tree()
     matches = tree.merge_tasks([action_task_end, action_task])
     self.expectThat(matches, Is(None))
     keys, nodes = zip(*tree.nodes())
     self.expectThat(
         list(keys),
         Equals(['f3a32bb3-ea6b-457c-aa99-08a3d0491ab4']))
     self.assertThat(
         list(_flattened_tasks(nodes)),
         MatchesListwise([Equals(action_task),
                          Equals(action_task_end)]))
コード例 #5
0
ファイル: test_tree.py プロジェクト: mithrandi/eliottree
 def test_merge_nested_tasks(self):
     """
     Merge nested tasks into the tree and retrieve an list of key-node
     pairs ordered by task timestamp.
     """
     tree = Tree()
     matches = tree.merge_tasks([action_task_end, action_task])
     self.expectThat(matches, Is(None))
     keys, nodes = zip(*tree.nodes())
     self.expectThat(
         list(keys),
         Equals(['f3a32bb3-ea6b-457c-aa99-08a3d0491ab4']))
     self.assertThat(
         list(_flattened_tasks(nodes)),
         MatchesListwise([Equals(action_task),
                          Equals(action_task_end)]))
コード例 #6
0
ファイル: test_tree.py プロジェクト: x0zzz/eliottree
 def test_merge_startless_tasks(self):
     """
     Merging a task that will never have a start parent creates a fake start
     task.
     """
     tree = Tree()
     missing_task = missing_start_task(action_task_end)
     matches = tree.merge_tasks([action_task_end])
     self.expectThat(matches, Is(None))
     keys, nodes = zip(*tree.nodes())
     self.expectThat(
         list(keys),
         Equals(['f3a32bb3-ea6b-457c-aa99-08a3d0491ab4']))
     self.assertThat(
         list(_flattened_tasks(nodes)),
         MatchesListwise([Equals(missing_task),
                          Equals(action_task_end)]))
コード例 #7
0
ファイル: test_tree.py プロジェクト: x0zzz/eliottree
 def test_merge_tasks(self):
     """
     Merge tasks into the tree and retrieve an list of key-node
     pairs ordered by task timestamp.
     """
     tree = Tree()
     matches = tree.merge_tasks([message_task, action_task])
     self.expectThat(matches, Is(None))
     keys, nodes = zip(*tree.nodes())
     self.expectThat(
         list(keys),
         Equals(['cdeb220d-7605-4d5f-8341-1a170222e308',
                 'f3a32bb3-ea6b-457c-aa99-08a3d0491ab4']))
     self.assertThat(
         list(_flattened_tasks(nodes)),
         MatchesListwise([Equals(message_task),
                          Equals(action_task)]))
コード例 #8
0
ファイル: test_tree.py プロジェクト: mithrandi/eliottree
 def test_merge_tasks(self):
     """
     Merge tasks into the tree and retrieve an list of key-node
     pairs ordered by task timestamp.
     """
     tree = Tree()
     matches = tree.merge_tasks([message_task, action_task])
     self.expectThat(matches, Is(None))
     keys, nodes = zip(*tree.nodes())
     self.expectThat(
         list(keys),
         Equals(['cdeb220d-7605-4d5f-8341-1a170222e308',
                 'f3a32bb3-ea6b-457c-aa99-08a3d0491ab4']))
     self.assertThat(
         list(_flattened_tasks(nodes)),
         MatchesListwise([Equals(message_task),
                          Equals(action_task)]))
コード例 #9
0
ファイル: test_tree.py プロジェクト: itamarst/eliottree
 def test_merge_startless_tasks(self):
     """
     Merging a task that will never have a start parent creates a fake start
     task.
     """
     tree = Tree()
     missing_task = missing_start_task(action_task_end)
     matches = tree.merge_tasks([action_task_end])
     self.expectThat(matches, Is(None))
     keys, nodes = zip(*tree.nodes())
     self.expectThat(
         list(keys),
         Equals(['f3a32bb3-ea6b-457c-aa99-08a3d0491ab4']))
     self.assertThat(
         list(_flattened_tasks(nodes)),
         MatchesListwise([Equals(missing_task),
                          Equals(action_task_end)]))
コード例 #10
0
ファイル: test_tree.py プロジェクト: jml/eliottree
 def test_merge_tasks_filtered(self):
     """
     Merge tasks into the tree with a filter function, generating a set of
     matches that can be used to prune the tree.
     """
     tree = Tree()
     filters = [lambda task: task.get(u'action_type') == u'app:action']
     matches = tree.merge_tasks([action_task, message_task], filters)
     keys, nodes = zip(*tree.nodes(matches))
     self.expectThat(
         list(keys),
         Equals(['f3a32bb3-ea6b-457c-aa99-08a3d0491ab4']))
     self.expectThat(
         list(keys),
         Equals(list(matches)))
     self.assertThat(
         [c.task for n in nodes for c in n.children()],
         MatchesListwise([Equals(action_task)]))
コード例 #11
0
ファイル: test_tree.py プロジェクト: x0zzz/eliottree
    def test_merge_tasks_filtered(self):
        """
        Merge tasks into the tree with a filter function, generating a set of
        matches that can be used to prune the tree.
        """
        tree = Tree()
        filters = [lambda task: task.get(u'action_type') == u'app:action']
        matches = tree.merge_tasks([action_task, message_task], filters)
        keys, nodes = zip(*tree.nodes(matches))
        self.expectThat(
            list(keys),
            Equals(['f3a32bb3-ea6b-457c-aa99-08a3d0491ab4']))
        self.expectThat(
            list(keys),
            Equals(list(matches)))

        self.assertThat(
            list(_flattened_tasks(nodes)),
            MatchesListwise([Equals(action_task)]))
コード例 #12
0
ファイル: test_tree.py プロジェクト: x0zzz/eliottree
 def test_initial(self):
     """
     The initial state of a tree is always empty.
     """
     tree = Tree()
     self.assertThat(tree.nodes(), Equals([]))
コード例 #13
0
ファイル: test_tree.py プロジェクト: mithrandi/eliottree
 def test_initial(self):
     """
     The initial state of a tree is always empty.
     """
     tree = Tree()
     self.assertThat(tree.nodes(), Equals([]))