[PR #8222/524d5883 backport][stable-8] Avoid deprecated utcnow() (#8243)

Avoid deprecated utcnow() (#8222)

Avoid deprecated utcnow().

(cherry picked from commit 524d5883b8)

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2024-04-20 10:21:02 +02:00 committed by GitHub
parent 83738f21a3
commit 4832100d76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 142 additions and 64 deletions

View file

@ -27,10 +27,10 @@ class TestSplunkClient(unittest.TestCase):
self.mock_host = Mock('MockHost')
self.mock_host.name = 'myhost'
@patch('ansible_collections.community.general.plugins.callback.splunk.datetime')
@patch('ansible_collections.community.general.plugins.callback.splunk.now')
@patch('ansible_collections.community.general.plugins.callback.splunk.open_url')
def test_timestamp_with_milliseconds(self, open_url_mock, mock_datetime):
mock_datetime.utcnow.return_value = datetime(2020, 12, 1)
def test_timestamp_with_milliseconds(self, open_url_mock, mock_now):
mock_now.return_value = datetime(2020, 12, 1)
result = TaskResult(host=self.mock_host, task=self.mock_task, return_data={}, task_fields=self.task_fields)
self.splunk.send_event(
@ -45,10 +45,10 @@ class TestSplunkClient(unittest.TestCase):
self.assertEqual(sent_data['event']['host'], 'my-host')
self.assertEqual(sent_data['event']['ip_address'], '1.2.3.4')
@patch('ansible_collections.community.general.plugins.callback.splunk.datetime')
@patch('ansible_collections.community.general.plugins.callback.splunk.now')
@patch('ansible_collections.community.general.plugins.callback.splunk.open_url')
def test_timestamp_without_milliseconds(self, open_url_mock, mock_datetime):
mock_datetime.utcnow.return_value = datetime(2020, 12, 1)
def test_timestamp_without_milliseconds(self, open_url_mock, mock_now):
mock_now.return_value = datetime(2020, 12, 1)
result = TaskResult(host=self.mock_host, task=self.mock_task, return_data={}, task_fields=self.task_fields)
self.splunk.send_event(