Michael Mortensen | 3e86c1e | 2019-11-21 15:51:54 -0700 | [diff] [blame] | 1 | # Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Unittests for build_api.py""" |
| 6 | |
Chris McDonald | e0a44a2 | 2020-04-15 06:55:20 -0600 | [diff] [blame] | 7 | from __future__ import division |
Michael Mortensen | 3e86c1e | 2019-11-21 15:51:54 -0700 | [diff] [blame] | 8 | |
Michael Mortensen | 3e86c1e | 2019-11-21 15:51:54 -0700 | [diff] [blame] | 9 | from chromite.api import router as router_lib |
Michael Mortensen | 3e86c1e | 2019-11-21 15:51:54 -0700 | [diff] [blame] | 10 | from chromite.lib import osutils |
| 11 | from chromite.scripts import build_api |
| 12 | |
Mike Frysinger | 898265b | 2020-02-10 23:49:12 -0500 | [diff] [blame] | 13 | |
Chris McDonald | e0a44a2 | 2020-04-15 06:55:20 -0600 | [diff] [blame] | 14 | def testSmoke(tmp_path, monkeypatch): |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 15 | """Basic confidence check""" |
Michael Mortensen | 3e86c1e | 2019-11-21 15:51:54 -0700 | [diff] [blame] | 16 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 17 | def stub(*_args, **_kwargs): |
| 18 | return True |
Alex Klein | d815ca6 | 2020-01-10 12:21:30 -0700 | [diff] [blame] | 19 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 20 | monkeypatch.setattr(router_lib.Router, "Route", stub) |
Alex Klein | d815ca6 | 2020-01-10 12:21:30 -0700 | [diff] [blame] | 21 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 22 | input_json = tmp_path / "input.json" |
| 23 | output_json = tmp_path / "output.json" |
Alex Klein | d815ca6 | 2020-01-10 12:21:30 -0700 | [diff] [blame] | 24 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 25 | osutils.WriteFile(input_json, "{}") |
Michael Mortensen | 3e86c1e | 2019-11-21 15:51:54 -0700 | [diff] [blame] | 26 | |
Alex Klein | 1699fab | 2022-09-08 08:46:06 -0600 | [diff] [blame^] | 27 | build_api.main( |
| 28 | [ |
| 29 | "--input-json", |
| 30 | str(input_json), |
| 31 | "--output-json", |
| 32 | str(output_json), |
| 33 | "chromite.api.VersionService/Get", |
| 34 | ] |
| 35 | ) |