fune/taskcluster/taskgraph/test/test_util_yaml.py
Andrew Halberstadt e44d45977e Bug 1696995 - [taskgraph] Drop requirement single match requirement in 'resolve_keyed_by' for test kind, r=taskgraph-reviewers,aki
At least in the 'test' kind, this is causing the keyed_by dicts to get very
complex as we need to ensure that each task is only matched by a single regex.
Instead, this makes them act more like case / match statements where the first
arm that matches the task will be used.

Differential Revision: https://phabricator.services.mozilla.com/D111727
2021-04-13 18:26:25 +00:00

51 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 textwrap import dedent
from taskgraph.util import yaml
from mozunit import main, MockedOpen
class TestYaml(unittest.TestCase):
def test_load(self):
with MockedOpen(
{
"/dir1/dir2/foo.yml": dedent(
"""\
prop:
- val1
"""
)
}
):
self.assertEqual(
yaml.load_yaml("/dir1/dir2", "foo.yml"), {"prop": ["val1"]}
)
def test_key_order(self):
with MockedOpen(
{
"/dir1/dir2/foo.yml": dedent(
"""\
job:
foo: 1
bar: 2
xyz: 3
"""
)
}
):
self.assertEqual(
list(yaml.load_yaml("/dir1/dir2", "foo.yml")["job"].keys()),
["foo", "bar", "xyz"],
)
if __name__ == "__main__":
main()