aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2024-01-30 10:12:31 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-01-30 18:57:45 +0000
commit9910f177b24bc741d182a0cb67c437b9fede2a4e (patch)
treebc015fb00e21baab1f341e67d61d5a32baf210ca
parent18e8096c516ec69141940002adaed379af7271d0 (diff)
downloadtoolchain-utils-9910f177b24bc741d182a0cb67c437b9fede2a4e.tar.gz
cros_utils: fix minor issues
The comment block was missing `Args`. Add it for consistency and added lint checking. Slight fixups in bugs_test are due to feedback from `cros lint` on module importing. BUG=b:322398536 TEST=None Change-Id: I09571313fb27e4d5e20ca70a11489ef70da6323a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/5249775 Reviewed-by: Ryan Beltran <ryanbeltran@chromium.org> Commit-Queue: George Burgess <gbiv@chromium.org> Tested-by: George Burgess <gbiv@chromium.org>
-rwxr-xr-xcros_utils/bugs.py23
-rwxr-xr-xcros_utils/bugs_test.py21
2 files changed, 22 insertions, 22 deletions
diff --git a/cros_utils/bugs.py b/cros_utils/bugs.py
index 5c77ba83..d8ef1759 100755
--- a/cros_utils/bugs.py
+++ b/cros_utils/bugs.py
@@ -161,17 +161,18 @@ def SendCronjobLog(
):
"""Sends the record of a cronjob to our bug infra.
- cronjob_name: The name of the cronjob. Expected to remain consistent over
- time.
- failed: Whether the job failed or not.
- message: Any seemingly relevant context. This is pasted verbatim in a bug,
- if the cronjob infra deems it worthy.
- turndown_time_hours: If nonzero, this cronjob will be considered
- turned down if more than `turndown_time_hours` pass without a report of
- success or failure. If zero, this job will not automatically be turned
- down.
- directory: The directory to write the report to. Defaults to our x20 bugs
- directory.
+ Args:
+ cronjob_name: The name of the cronjob. Expected to remain consistent
+ over time.
+ failed: Whether the job failed or not.
+ message: Any seemingly relevant context. This is pasted verbatim in a
+ bug, if the cronjob infra deems it worthy.
+ turndown_time_hours: If nonzero, this cronjob will be considered turned
+ down if more than `turndown_time_hours` pass without a report of
+ success or failure. If zero, this job will not automatically be
+ turned down.
+ directory: The directory to write the report to. Defaults to our x20
+ bugs directory.
"""
json_object = {
"name": cronjob_name,
diff --git a/cros_utils/bugs_test.py b/cros_utils/bugs_test.py
index 1ee6bfe4..4e5ab5f2 100755
--- a/cros_utils/bugs_test.py
+++ b/cros_utils/bugs_test.py
@@ -14,8 +14,7 @@ import os
from pathlib import Path
import tempfile
import unittest
-from unittest import mock
-from unittest.mock import patch
+import unittest.mock
from cros_utils import bugs
@@ -65,7 +64,7 @@ class Tests(unittest.TestCase):
},
)
- @patch.object(bugs, "_WriteBugJSONFile")
+ @unittest.mock.patch.object(bugs, "_WriteBugJSONFile")
def testAppendingToBugsSeemsToWork(self, mock_write_json_file):
"""Tests AppendToExistingBug."""
bugs.AppendToExistingBug(1234, "hello, world!")
@@ -78,7 +77,7 @@ class Tests(unittest.TestCase):
None,
)
- @patch.object(bugs, "_WriteBugJSONFile")
+ @unittest.mock.patch.object(bugs, "_WriteBugJSONFile")
def testBugCreationSeemsToWork(self, mock_write_json_file):
"""Tests CreateNewBug."""
test_case_additions = (
@@ -123,7 +122,7 @@ class Tests(unittest.TestCase):
)
mock_write_json_file.reset_mock()
- @patch.object(bugs, "_WriteBugJSONFile")
+ @unittest.mock.patch.object(bugs, "_WriteBugJSONFile")
def testCronjobLogSendingSeemsToWork(self, mock_write_json_file):
"""Tests SendCronjobLog."""
bugs.SendCronjobLog("my_name", False, "hello, world!")
@@ -137,7 +136,7 @@ class Tests(unittest.TestCase):
None,
)
- @patch.object(bugs, "_WriteBugJSONFile")
+ @unittest.mock.patch.object(bugs, "_WriteBugJSONFile")
def testCronjobLogSendingSeemsToWorkWithTurndown(
self, mock_write_json_file
):
@@ -180,7 +179,7 @@ class Tests(unittest.TestCase):
fourth = gen.generate_json_file_name(_ARBITRARY_DATETIME)
self.assertLess(third, fourth)
- @patch.object(os, "getpid")
+ @unittest.mock.patch.object(os, "getpid")
def testForkingProducesADifferentReport(self, mock_getpid):
"""Tests that _FileNameGenerator gives us sorted file names."""
gen = bugs._FileNameGenerator()
@@ -194,24 +193,24 @@ class Tests(unittest.TestCase):
child_file = gen.generate_json_file_name(_ARBITRARY_DATETIME)
self.assertNotEqual(parent_file, child_file)
- @patch.object(bugs, "_WriteBugJSONFile")
+ @unittest.mock.patch.object(bugs, "_WriteBugJSONFile")
def testCustomDirectoriesArePassedThrough(self, mock_write_json_file):
directory = "/path/to/somewhere/interesting"
bugs.AppendToExistingBug(1, "foo", directory=directory)
mock_write_json_file.assert_called_once_with(
- mock.ANY, mock.ANY, directory
+ unittest.mock.ANY, unittest.mock.ANY, directory
)
mock_write_json_file.reset_mock()
bugs.CreateNewBug(1, "title", "body", directory=directory)
mock_write_json_file.assert_called_once_with(
- mock.ANY, mock.ANY, directory
+ unittest.mock.ANY, unittest.mock.ANY, directory
)
mock_write_json_file.reset_mock()
bugs.SendCronjobLog("cronjob", False, "message", directory=directory)
mock_write_json_file.assert_called_once_with(
- mock.ANY, mock.ANY, directory
+ unittest.mock.ANY, unittest.mock.ANY, directory
)
def testWriteBugJSONFileWritesToGivenDirectory(self):