Files
firefox/taskcluster/taskgraph/test/test_parameters.py
T
Dustin J. Mitchell 2db03e8aeb Bug 1258497: Implement a new taskgraph generation system; r=gps
The `taskgraph` package generates TaskCluster task graphs based on collections
of task "kinds".  Initially, there is only one kind, the "legacy" kind, which
reads the YAML files from `testing/taskcluster/tasks` to generate the task
graph.

Try syntax is implemented by filtering the tasks in the taskgraph after it has
been created, then extending the result to include any prerequisite tasks.

A collection of `mach taskgraph` subcommands are provided for developers to
extend or debug the task-graph generation process.

MozReview-Commit-ID: 1TJCns4XxZ8
2016-05-16 22:53:22 +00:00

42 lines
1.3 KiB
Python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
import unittest
from ..parameters import Parameters, load_parameters_file
from mozunit import main, MockedOpen
class TestParameters(unittest.TestCase):
def test_Parameters_immutable(self):
p = Parameters(x=10, y=20)
def assign():
p['x'] = 20
self.assertRaises(Exception, assign)
def test_Parameters_KeyError(self):
p = Parameters(x=10, y=20)
self.assertRaises(KeyError, lambda: p['z'])
def test_Parameters_get(self):
p = Parameters(x=10, y=20)
self.assertEqual(p['x'], 10)
def test_load_parameters_file_yaml(self):
with MockedOpen({"params.yml": "some: data\n"}):
self.assertEqual(
load_parameters_file({'parameters': 'params.yml'}),
{'some': 'data'})
def test_load_parameters_file_json(self):
with MockedOpen({"params.json": '{"some": "data"}'}):
self.assertEqual(
load_parameters_file({'parameters': 'params.json'}),
{'some': 'data'})
if __name__ == '__main__':
main()