mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
[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:
parent
83738f21a3
commit
4832100d76
19 changed files with 142 additions and 64 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue