Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.assertEqual(OfxParser.parseOfxDateTime('19991201120000 [1:ITT]'),
datetime(1999, 12, 1, 11, 0))
self.assertEqual(
OfxParser.parseOfxDateTime('19881201230100 [-5:EST]'),
datetime(1988, 12, 2, 4, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120229230100 [-6:CAT]'),
datetime(2012, 3, 1, 5, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5.5:XXX]'),
datetime(2012, 4, 12, 17, 30))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5:XXX]'),
datetime(2012, 4, 12, 17))
self.assertEqual(
OfxParser.parseOfxDateTime('20120922230000 [+9:JST]'),
datetime(2012, 9, 22, 14, 0))
def test_parses_time_offset(self):
''' Test that we handle GMT offset '''
self.assertEqual(OfxParser.parseOfxDateTime('20001201120000 [0:GMT]'),
datetime(2000, 12, 1, 12, 0))
self.assertEqual(OfxParser.parseOfxDateTime('19991201120000 [1:ITT]'),
datetime(1999, 12, 1, 11, 0))
self.assertEqual(
OfxParser.parseOfxDateTime('19881201230100 [-5:EST]'),
datetime(1988, 12, 2, 4, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120229230100 [-6:CAT]'),
datetime(2012, 3, 1, 5, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5.5:XXX]'),
datetime(2012, 4, 12, 17, 30))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5:XXX]'),
datetime(2012, 4, 12, 17))
self.assertEqual(
OfxParser.parseOfxDateTime('20120922230000 [+9:JST]'),
datetime(2012, 9, 22, 14, 0))
def test_parses_correct_time(self):
'''Test whether it can parse correct time for some valid time fields'''
self.assertEqual(OfxParser.parseOfxDateTime('19881201'),
datetime(1988, 12, 1, 0, 0))
self.assertEqual(OfxParser.parseOfxDateTime('19881201230100'),
datetime(1988, 12, 1, 23, 1))
self.assertEqual(OfxParser.parseOfxDateTime('20120229230100'),
datetime(2012, 2, 29, 23, 1))
def test_bad_format(self):
''' A poorly formatted string should throw a ValueError '''
bad_string = 'abcdLOL!'
self.assertRaises(ValueError, OfxParser.parseOfxDateTime, bad_string)
bad_but_close_string = '881103'
self.assertRaises(ValueError, OfxParser.parseOfxDateTime, bad_but_close_string)
no_month_string = '19881301'
self.assertRaises(ValueError, OfxParser.parseOfxDateTime, no_month_string)
def test_parses_correct_time(self):
'''Test whether it can parse correct time for some valid time fields'''
self.assertEqual(OfxParser.parseOfxDateTime('19881201'),
datetime(1988, 12, 1, 0, 0))
self.assertEqual(OfxParser.parseOfxDateTime('19881201230100'),
datetime(1988, 12, 1, 23, 1))
self.assertEqual(OfxParser.parseOfxDateTime('20120229230100'),
datetime(2012, 2, 29, 23, 1))
def test_parses_time_offset(self):
''' Test that we handle GMT offset '''
self.assertEqual(OfxParser.parseOfxDateTime('20001201120000 [0:GMT]'),
datetime(2000, 12, 1, 12, 0))
self.assertEqual(OfxParser.parseOfxDateTime('19991201120000 [1:ITT]'),
datetime(1999, 12, 1, 11, 0))
self.assertEqual(
OfxParser.parseOfxDateTime('19881201230100 [-5:EST]'),
datetime(1988, 12, 2, 4, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120229230100 [-6:CAT]'),
datetime(2012, 3, 1, 5, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5.5:XXX]'),
datetime(2012, 4, 12, 17, 30))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5:XXX]'),
datetime(2012, 4, 12, 17))
self.assertEqual(
OfxParser.parseOfxDateTime('20120922230000 [+9:JST]'),
datetime(2012, 9, 22, 14, 0))
def test_parses_time_offset(self):
''' Test that we handle GMT offset '''
self.assertEqual(OfxParser.parseOfxDateTime('20001201120000 [0:GMT]'),
datetime(2000, 12, 1, 12, 0))
self.assertEqual(OfxParser.parseOfxDateTime('19991201120000 [1:ITT]'),
datetime(1999, 12, 1, 11, 0))
self.assertEqual(
OfxParser.parseOfxDateTime('19881201230100 [-5:EST]'),
datetime(1988, 12, 2, 4, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120229230100 [-6:CAT]'),
datetime(2012, 3, 1, 5, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5.5:XXX]'),
datetime(2012, 4, 12, 17, 30))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5:XXX]'),
datetime(2012, 4, 12, 17))
self.assertEqual(
OfxParser.parseOfxDateTime('20120922230000 [+9:JST]'),
datetime(2012, 9, 22, 14, 0))
def test_parses_correct_time(self):
'''Test whether it can parse correct time for some valid time fields'''
self.assertEqual(OfxParser.parseOfxDateTime('19881201'),
datetime(1988, 12, 1, 0, 0))
self.assertEqual(OfxParser.parseOfxDateTime('19881201230100'),
datetime(1988, 12, 1, 23, 1))
self.assertEqual(OfxParser.parseOfxDateTime('20120229230100'),
datetime(2012, 2, 29, 23, 1))
def test_parses_time_offset(self):
''' Test that we handle GMT offset '''
self.assertEqual(OfxParser.parseOfxDateTime('20001201120000 [0:GMT]'),
datetime(2000, 12, 1, 12, 0))
self.assertEqual(OfxParser.parseOfxDateTime('19991201120000 [1:ITT]'),
datetime(1999, 12, 1, 11, 0))
self.assertEqual(
OfxParser.parseOfxDateTime('19881201230100 [-5:EST]'),
datetime(1988, 12, 2, 4, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120229230100 [-6:CAT]'),
datetime(2012, 3, 1, 5, 1))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5.5:XXX]'),
datetime(2012, 4, 12, 17, 30))
self.assertEqual(
OfxParser.parseOfxDateTime('20120412120000 [-5:XXX]'),
datetime(2012, 4, 12, 17))
self.assertEqual(
OfxParser.parseOfxDateTime('20120922230000 [+9:JST]'),
datetime(2012, 9, 22, 14, 0))
def test_returns_none(self):
self.assertIsNone(OfxParser.parseOfxDateTime('00000000'))