diff options
author | Jhon Honce <jhonce@redhat.com> | 2018-07-12 19:26:14 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2018-07-13 12:50:12 -0700 |
commit | 74ccd9ce5f29a1df4ffe70b4d8bd00c29d5d9d15 (patch) | |
tree | 75ba256d70545d79aa61d7c57c20df886be1555f /contrib/python/podman/test/test_libs.py | |
parent | 44b523c946c88e540b50d7ba59f441b5f8e0bad0 (diff) | |
download | podman-74ccd9ce5f29a1df4ffe70b4d8bd00c29d5d9d15.tar.gz podman-74ccd9ce5f29a1df4ffe70b4d8bd00c29d5d9d15.tar.bz2 podman-74ccd9ce5f29a1df4ffe70b4d8bd00c29d5d9d15.zip |
Update python directories to better support setup.py
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'contrib/python/podman/test/test_libs.py')
-rw-r--r-- | contrib/python/podman/test/test_libs.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/contrib/python/podman/test/test_libs.py b/contrib/python/podman/test/test_libs.py new file mode 100644 index 000000000..202bed1d8 --- /dev/null +++ b/contrib/python/podman/test/test_libs.py @@ -0,0 +1,53 @@ +import datetime +import unittest + +import podman + + +class TestLibs(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + pass + + def test_parse(self): + expected = datetime.datetime.strptime( + '2018-05-08T14:12:53.797795-0700', '%Y-%m-%dT%H:%M:%S.%f%z') + for v in [ + '2018-05-08T14:12:53.797795191-07:00', + '2018-05-08T14:12:53.797795-07:00', + '2018-05-08T14:12:53.797795-0700', + '2018-05-08 14:12:53.797795191 -0700 MST', + ]: + actual = podman.datetime_parse(v) + self.assertEqual(actual, expected) + + expected = datetime.datetime.strptime( + '2018-05-08T14:12:53.797795-0000', '%Y-%m-%dT%H:%M:%S.%f%z') + for v in [ + '2018-05-08T14:12:53.797795191Z', + '2018-05-08T14:12:53.797795191z', + ]: + actual = podman.datetime_parse(v) + self.assertEqual(actual, expected) + + actual = podman.datetime_parse(datetime.datetime.now().isoformat()) + self.assertIsNotNone(actual) + + def test_parse_fail(self): + for v in [ + 'There is no time here.', + ]: + with self.assertRaises(ValueError): + podman.datetime_parse(v) + + def test_format(self): + expected = '2018-05-08T18:24:52.753227-07:00' + dt = podman.datetime_parse(expected) + actual = podman.datetime_format(dt) + self.assertEqual(actual, expected) + + +if __name__ == '__main__': + unittest.main() |