1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 from __future__
import absolute_import
9 from taskgraph
.decision
import full_task_graph_to_runnable_jobs
10 from taskgraph
.graph
import Graph
11 from taskgraph
.taskgraph
import TaskGraph
12 from taskgraph
.task
import Task
13 from mozunit
import main
16 class TestRunnableJobs(unittest
.TestCase
):
41 'groupName': 'Some group',
53 def make_taskgraph(self
, tasks
):
54 label_to_taskid
= {k
: k
+ '-tid' for k
in tasks
}
55 for label
, task_id
in label_to_taskid
.iteritems():
56 tasks
[label
].task_id
= task_id
57 graph
= Graph(nodes
=set(tasks
), edges
=set())
58 taskgraph
= TaskGraph(tasks
, graph
)
59 return taskgraph
, label_to_taskid
61 def test_taskgraph_to_runnable_jobs(self
):
62 tg
, label_to_taskid
= self
.make_taskgraph({
63 t
['label']: Task(**t
) for t
in self
.tasks
[:]
66 res
= full_task_graph_to_runnable_jobs(tg
.to_json())
68 self
.assertEqual(res
, {
73 'collection': {'opt': True},
74 'groupName': 'Some group',
82 if __name__
== '__main__':