• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The ChromiumOS Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Exposes functions that construct SuiteSet related proto messages."""
6
7load(
8    "@proto//chromiumos/test/api/suite_set.proto",
9    suite_set_pb = "chromiumos.test.api",
10)
11load(
12    "@proto//chromiumos/test/api/test_case.proto",
13    test_case_pb = "chromiumos.test.api",
14)
15load(
16    "@proto//chromiumos/test/api/test_case_metadata.proto",
17    test_case_metadata_pb = "chromiumos.test.api",
18)
19
20def _create_suite_list(suites):
21    return suite_set_pb.SuiteList(suites = suites)
22
23def _create_suite(suite_id, owners, bug_component, criteria, tests):
24    return suite_set_pb.Suite(
25        id = _create_suite_id(suite_id),
26        metadata = _create_metadata(owners, bug_component, criteria),
27        tests = [_create_test_id(test) for test in tests],
28    )
29
30def _create_suite_set_list(suite_sets):
31    return suite_set_pb.SuiteSetList(suite_sets = suite_sets)
32
33def _create_suite_set(
34        suite_set_id,
35        owners,
36        bug_component,
37        criteria,
38        suite_sets,
39        suites):
40    return suite_set_pb.SuiteSet(
41        id = _create_suite_set_id(suite_set_id),
42        metadata = _create_metadata(owners, bug_component, criteria),
43        suite_sets = [_create_suite_set_id(suite_set) for suite_set in suite_sets],
44        suites = [_create_suite_id(suite) for suite in suites],
45    )
46
47def _create_suite_id(suite_id):
48    return suite_set_pb.Suite.Id(value = suite_id)
49
50def _create_suite_set_id(suite_set_id):
51    return suite_set_pb.SuiteSet.Id(value = suite_set_id)
52
53def _create_test_id(test_id):
54    return test_case_pb.TestCase.Id(value = test_id)
55
56def _create_metadata(owners, bug_component, criteria):
57    return suite_set_pb.Metadata(
58        owners = [_create_owner(owner) for owner in owners],
59        bug_component = _create_bug_component(bug_component),
60        criteria = _create_criteria(criteria),
61    )
62
63def _create_bug_component(bug_component):
64    return test_case_metadata_pb.BugComponent(value = bug_component)
65
66def _create_criteria(criteria):
67    return test_case_metadata_pb.Criteria(value = criteria)
68
69def _create_owner(owner):
70    return test_case_metadata_pb.Contact(email = owner)
71
72create = struct(
73    suite = _create_suite,
74    suite_list = _create_suite_list,
75    suite_set = _create_suite_set,
76    suite_set_list = _create_suite_set_list,
77)
78