pytest: Clean up & remove 'sigterm' marker
tee.Tee is no longer used by the Build API, so we can remove these tests
now. This file was the only one with the sigterm marker so delete the
marker entirely now that the tests pass.
BUG=chromium:1062676
TEST=`run_pytest`
Change-Id: I5fd1eab01e402e32f9518a534d4b1a25f8807fe3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2150506
Tested-by: Chris McDonald <cjmcdonald@chromium.org>
Auto-Submit: Chris McDonald <cjmcdonald@chromium.org>
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Commit-Queue: Chris McDonald <cjmcdonald@chromium.org>
diff --git a/scripts/build_api_unittest.py b/scripts/build_api_unittest.py
index f67e563..ffb2ef8 100644
--- a/scripts/build_api_unittest.py
+++ b/scripts/build_api_unittest.py
@@ -6,57 +6,34 @@
"""Unittests for build_api.py"""
from __future__ import print_function
+from __future__ import division
-import os
import sys
from chromite.api import router as router_lib
-from chromite.lib import cros_test_lib
from chromite.lib import osutils
from chromite.scripts import build_api
-pytestmark = cros_test_lib.pytestmark_sigterm
-
-
assert sys.version_info >= (3, 6), 'This module requires Python 3.6+'
-class BuildApiScriptTest(cros_test_lib.MockTempDirTestCase):
- """Tests for main()"""
+def testSmoke(tmp_path, monkeypatch):
+ """Basic sanity check"""
- def setUp(self):
- self.find_mock = self.PatchObject(router_lib.Router, 'Route')
- self.input_json = os.path.join(self.tempdir, 'input.json')
- self.output_json = os.path.join(self.tempdir, 'output.json')
- self.config_json = os.path.join(self.tempdir, 'config.json')
- self.tee_log = os.path.join(self.tempdir, 'tee_out.txt')
+ def dummy(*_args, **_kwargs):
+ return True
- tee_config = '{"log_path": "%s"}' % self.tee_log
+ monkeypatch.setattr(router_lib.Router, 'Route', dummy)
- osutils.WriteFile(self.input_json, '{}')
- osutils.WriteFile(self.config_json, tee_config)
+ input_json = tmp_path / 'input.json'
+ output_json = tmp_path / 'output.json'
+ osutils.WriteFile(input_json, '{}')
- def testSmoke(self):
- """Basic sanity check"""
- build_api.main(['--input-json', self.input_json,
- '--output-json', self.output_json,
- 'chromite.api.VersionService/Get'])
-
- def testTee(self):
- """Call build_api with tee-log set, verify log contents."""
- build_api.main(['--input-json', self.input_json,
- '--output-json', self.output_json,
- '--config-json', self.config_json,
- 'chromite.api.VersionService/Get'])
- contents = osutils.ReadFile(self.tee_log)
- self.assertIn('Teeing stdout', contents)
-
- def testEnvTee(self):
- """Call build_api with tee-log set, verify log contents."""
- os.environ['BUILD_API_TEE_LOG_FILE'] = self.tee_log
- build_api.main(['--input-json', self.input_json,
- '--output-json', self.output_json,
- 'chromite.api.VersionService/Get'])
- contents = osutils.ReadFile(self.tee_log)
- self.assertIn('Teeing stdout and stderr to env path ', contents)
+ build_api.main([
+ '--input-json',
+ str(input_json),
+ '--output-json',
+ str(output_json),
+ 'chromite.api.VersionService/Get',
+ ])