From 7761dabac264fd400641f5c77df28a92fb44b798 Mon Sep 17 00:00:00 2001 From: Ruben Verweij Date: Fri, 17 Feb 2017 12:29:55 +0100 Subject: [PATCH] Test date parsing --- tests/test_common.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/test_common.py b/tests/test_common.py index ae5099d..da2e2a8 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,6 +1,7 @@ import unittest -from nd2reader.common import parse_version +import six +from nd2reader.common import parse_version, parse_date class TestCommon(unittest.TestCase): @@ -15,3 +16,19 @@ class TestCommon(unittest.TestCase): actual = parse_version(data) expected = (3, 0) self.assertTupleEqual(actual, expected) + + def test_parse_date_24(self): + date_format = "%m/%d/%Y %H:%M:%S" + date = '02/13/2016 23:43:37' + textinfo = {six.b('TextInfoItem9'): six.b(date)} + result = parse_date(textinfo) + self.assertEqual(result.strftime(date_format), date) + + def test_parse_date_12(self): + date_format = "%m/%d/%Y %I:%M:%S %p" + date = '02/13/2016 11:43:37 PM' + textinfo = {six.b('TextInfoItem9'): six.b(date)} + result = parse_date(textinfo) + self.assertEqual(result.strftime(date_format), date) + +