ansible/test/units/module_utils/facts
Sam Doran 719c40bfdf
[stable-2.10] facts - fix incorrect time for some date_time_facts (#70665) (#70996)
* [stable-2.10] facts - fix incorrect time for some date_time_facts (#70665)

The iso8601_micro and iso8601 facts incorrectly called now.utcnow(), resulting
in a new timestamp at the time it was called, not a conversion of the previously
stored timestamp.

Correct this by capturing the UTC timestamp once then calculating the local
time using the UTC offset of the current system.

* Use time.time() for getting the current time
* Convert from that stored epoch timestamp to local and UTC times
* Used existing timestamp for epoch time
* Add unit tests that validate the formate of the return value rather than an exact value since mocking time and timezone is non-trivial
(cherry picked from commit c4f442ed5a)

Co-authored-by: Sam Doran <sdoran@redhat.com>

* Remove tests for tz_dst since that only exists in newer versions
2020-07-30 13:37:19 -07:00
..
fixtures [stable-2.10] Handle Slackware OS version strings containing a plus (“+”) (#68142) (#70717) 2020-07-21 11:21:07 -07:00
hardware [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00
network [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00
other [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00
system [stable-2.10] Handle Slackware OS version strings containing a plus (“+”) (#68142) (#70717) 2020-07-21 11:21:07 -07:00
__init__.py
base.py [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00
test_ansible_collector.py [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00
test_collector.py [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00
test_collectors.py [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00
test_date_time.py [stable-2.10] facts - fix incorrect time for some date_time_facts (#70665) (#70996) 2020-07-30 13:37:19 -07:00
test_facts.py [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00
test_timeout.py [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00
test_utils.py [stable-2.10] Clean up unit test boilerplate. 2020-07-13 18:28:02 -07:00