示例#1
0
 def test_cli1(self):
     """single timezone, default format"""
     a = ['1457128501']
     t = ['UTC']
     f = []
     h = kron._cli(self._args(a, t, f))
     w = '2016-03-04 21:55:01 UTC'
     self.assertEqual(h, w)
示例#2
0
 def test_cli1(self):
     """single timezone, default format"""
     a = ['1457128501']
     t = ['UTC']
     f = []
     h = kron._cli(self._args(a, t, f))
     w = '2016-03-04 21:55:01 UTC'
     self.assertEqual(h, w)
示例#3
0
 def test_cli2(self):
     """single timezone, single format"""
     a = ['1457128501']
     t = ['UTC']
     f = ['national']
     h = kron._cli(self._args(a, t, f))
     w = 'Fri Mar 04 21:55:01 UTC 2016'
     self.assertEqual(h, w)
示例#4
0
 def test_cli2(self):
     """single timezone, single format"""
     a = ['1457128501']
     t = ['UTC']
     f = ['national']
     h = kron._cli(self._args(a, t, f))
     w = 'Fri Mar 04 21:55:01 UTC 2016'
     self.assertEqual(h, w)
示例#5
0
 def test_cli6(self):
     """timestamp in base format"""
     a = ['2016-03-04 21:55:01']
     T = ['UTC']
     t = ['UTC']
     f = []
     h = kron._cli(self._args(a, t, f, T))
     w = '2016-03-04 21:55:01 UTC'
     self.assertEqual(h, w)
示例#6
0
 def test_cli6(self):
     """timestamp in base format"""
     a = ['2016-03-04 21:55:01']
     T = ['UTC']
     t = ['UTC']
     f = []
     h = kron._cli(self._args(a, t, f, T))
     w = '2016-03-04 21:55:01 UTC'
     self.assertEqual(h, w)
示例#7
0
 def test_cli7(self):
     """timestamp in iso8601 format"""
     a = ['2014-01-23T09:06:12Z']
     T = []
     F = ['iso8601']
     t = ['UTC']
     f = []
     h = kron._cli(self._args(a, t, f, T, F))
     w = '2014-01-23 09:06:12 UTC'
     self.assertEqual(h, w)
示例#8
0
 def test_cli7(self):
     """timestamp in iso8601 format"""
     a = ['2014-01-23T09:06:12Z']
     T = []
     F = ['iso8601']
     t = ['UTC']
     f = []
     h = kron._cli(self._args(a, t, f, T, F))
     w = '2014-01-23 09:06:12 UTC'
     self.assertEqual(h, w)
示例#9
0
 def test_cli5(self):
     """multiple timezones, single format"""
     a = ['1457128501']
     t = ['UTC', 'PST8PDT']
     f = ['rfc2822']
     w = kron._json({a[0]:dict(
         PST8PDT=dict(rfc2822='Fri, 04 Mar 2016 13:55:01 -0800'),
         UTC=dict(rfc2822='Fri, 04 Mar 2016 21:55:01 +0000'),
     )})
     h = kron._cli(self._args(a, t, f))
     self.assertEqual(h, w)
示例#10
0
 def test_cli4(self):
     """multiple timezones, default format"""
     a = ['1457128501']
     t = ['UTC', 'EST5EDT']
     f = []
     h = kron._cli(self._args(a, t, f))
     w = kron._json({a[0]:dict(
         EST5EDT=dict(basetz='2016-03-04 16:55:01 EST'),
         UTC=dict(basetz='2016-03-04 21:55:01 UTC'),
     )})
     self.assertEqual(h, w)
示例#11
0
 def test_cli4(self):
     """multiple timezones, default format"""
     a = ['1457128501']
     t = ['UTC', 'EST5EDT']
     f = []
     h = kron._cli(self._args(a, t, f))
     w = kron._json({
         a[0]:
         dict(
             EST5EDT=dict(basetz='2016-03-04 16:55:01 EST'),
             UTC=dict(basetz='2016-03-04 21:55:01 UTC'),
         )
     })
     self.assertEqual(h, w)
示例#12
0
 def test_cli5(self):
     """multiple timezones, single format"""
     a = ['1457128501']
     t = ['UTC', 'PST8PDT']
     f = ['rfc2822']
     w = kron._json({
         a[0]:
         dict(
             PST8PDT=dict(rfc2822='Fri, 04 Mar 2016 13:55:01 -0800'),
             UTC=dict(rfc2822='Fri, 04 Mar 2016 21:55:01 +0000'),
         )
     })
     h = kron._cli(self._args(a, t, f))
     self.assertEqual(h, w)
示例#13
0
 def test_cli_search_timezone(self):
     h = kron._cli(['-s', ''])
     w = '\n'.join(pytz.all_timezones)
     self.assertEqual(h, w)
示例#14
0
 def test_cli3(self):
     """single timezone, multiple formats
     multiple timezones, multiple formats"""
     a = ['1457128501']
     w = {a[0]:dict(UTC=dict(
         HH='21',
         HHMM='2155',
         HHMMSS='215501',
         HH_MM='21:55',
         HH_MM_SS='21:55:01',
         MM='55',
         SS='01',
         abbr_date='Fri, Mar 04, 2016',
         abbr_month='Mar',
         abbr_weekday='Fri',
         ampm='PM',
         base='2016-03-04 21:55:01',
         basetz='2016-03-04 21:55:01 UTC',
         ccyy='2016',
         ccyymm='201603',
         ccyymmdd='20160304',
         date='Friday, March 04, 2016',
         dd='04',
         hh='09',
         hh_MM='09:55',
         hh_MM_SS='09:55:01',
         hh_MM_SS_ampm='09:55:01 PM',
         hh_MM_ampm='09:55 PM',
         hours='21',
         hours12='09',
         hours24='21',
         iso8601='2016-03-04T21:55:01Z',
         julian='064',
         microseconds='000000',
         minutes='55',
         mm='03',
         mm_dd_yy='03/04/16',
         mmdd='0304',
         mon='Mar',
         month='March',
         national='Fri Mar 04 21:55:01 UTC 2016',
         national_date='03/04/16',
         national_time='21:55:01',
         rfc2822='Fri, 04 Mar 2016 21:55:01 +0000',
         seconds='01',
         tz='UTC',
         tz_offset='+0000',
         week_number_mon='09',
         week_number_sun='09',
         weekday='Friday',
         year='2016',
         yy='16',
         yymm='1603',
         yymmdd='160304',
         yyyy='2016',
         yyyy_mm_dd='2016/03/04',
         yyyymm='201603',
         yyyymmdd='20160304',
     ))}
     t = ['UTC']
     f = sorted(w[a[0]]['UTC'].keys())
     self.assertEqual(kron._cli(self._args(a, t, f)), kron._json(w))
     t.append('PST8PDT')
     w[a[0]]['PST8PDT'] = dict(
         HH='13',
         HHMM='1355',
         HHMMSS='135501',
         HH_MM='13:55',
         HH_MM_SS='13:55:01',
         MM='55',
         SS='01',
         abbr_date='Fri, Mar 04, 2016',
         abbr_month='Mar',
         abbr_weekday='Fri',
         ampm='PM',
         base='2016-03-04 13:55:01',
         basetz='2016-03-04 13:55:01 PST',
         ccyy='2016',
         ccyymm='201603',
         ccyymmdd='20160304',
         date='Friday, March 04, 2016',
         dd='04',
         hh='01',
         hh_MM='01:55',
         hh_MM_SS='01:55:01',
         hh_MM_SS_ampm='01:55:01 PM',
         hh_MM_ampm='01:55 PM',
         hours='13',
         hours12='01',
         hours24='13',
         iso8601='2016-03-04T21:55:01Z',
         julian='064',
         microseconds='000000',
         minutes='55',
         mm='03',
         mm_dd_yy='03/04/16',
         mmdd='0304',
         mon='Mar',
         month='March',
         national='Fri Mar 04 13:55:01 PST 2016',
         national_date='03/04/16',
         national_time='13:55:01',
         rfc2822='Fri, 04 Mar 2016 13:55:01 -0800',
         seconds='01',
         tz='PST',
         tz_offset='-0800',
         week_number_mon='09',
         week_number_sun='09',
         weekday='Friday',
         year='2016',
         yy='16',
         yymm='1603',
         yymmdd='160304',
         yyyy='2016',
         yyyy_mm_dd='2016/03/04',
         yyyymm='201603',
         yyyymmdd='20160304',
     )
     self.assertEqual(kron._cli(self._args(a, t, f)), kron._json(w))
示例#15
0
 def test_cli3(self):
     """single timezone, multiple formats
     multiple timezones, multiple formats"""
     a = ['1457128501']
     w = {
         a[0]:
         dict(UTC=dict(
             HH='21',
             HHMM='2155',
             HHMMSS='215501',
             HH_MM='21:55',
             HH_MM_SS='21:55:01',
             MM='55',
             SS='01',
             abbr_date='Fri, Mar 04, 2016',
             abbr_month='Mar',
             abbr_weekday='Fri',
             ampm='PM',
             base='2016-03-04 21:55:01',
             basetz='2016-03-04 21:55:01 UTC',
             ccyy='2016',
             ccyymm='201603',
             ccyymmdd='20160304',
             date='Friday, March 04, 2016',
             dd='04',
             hh='09',
             hh_MM='09:55',
             hh_MM_SS='09:55:01',
             hh_MM_SS_ampm='09:55:01 PM',
             hh_MM_ampm='09:55 PM',
             hours='21',
             hours12='09',
             hours24='21',
             iso8601='2016-03-04T21:55:01Z',
             julian='064',
             microseconds='000000',
             minutes='55',
             mm='03',
             mm_dd_yy='03/04/16',
             mmdd='0304',
             mon='Mar',
             month='March',
             national='Fri Mar 04 21:55:01 UTC 2016',
             national_date='03/04/16',
             national_time='21:55:01',
             rfc2822='Fri, 04 Mar 2016 21:55:01 +0000',
             seconds='01',
             tz='UTC',
             tz_offset='+0000',
             week_number_mon='09',
             week_number_sun='09',
             weekday='Friday',
             year='2016',
             yy='16',
             yymm='1603',
             yymmdd='160304',
             yyyy='2016',
             yyyy_mm_dd='2016/03/04',
             yyyymm='201603',
             yyyymmdd='20160304',
         ))
     }
     t = ['UTC']
     f = sorted(w[a[0]]['UTC'].keys())
     self.assertEqual(kron._cli(self._args(a, t, f)), kron._json(w))
     t.append('PST8PDT')
     w[a[0]]['PST8PDT'] = dict(
         HH='13',
         HHMM='1355',
         HHMMSS='135501',
         HH_MM='13:55',
         HH_MM_SS='13:55:01',
         MM='55',
         SS='01',
         abbr_date='Fri, Mar 04, 2016',
         abbr_month='Mar',
         abbr_weekday='Fri',
         ampm='PM',
         base='2016-03-04 13:55:01',
         basetz='2016-03-04 13:55:01 PST',
         ccyy='2016',
         ccyymm='201603',
         ccyymmdd='20160304',
         date='Friday, March 04, 2016',
         dd='04',
         hh='01',
         hh_MM='01:55',
         hh_MM_SS='01:55:01',
         hh_MM_SS_ampm='01:55:01 PM',
         hh_MM_ampm='01:55 PM',
         hours='13',
         hours12='01',
         hours24='13',
         iso8601='2016-03-04T21:55:01Z',
         julian='064',
         microseconds='000000',
         minutes='55',
         mm='03',
         mm_dd_yy='03/04/16',
         mmdd='0304',
         mon='Mar',
         month='March',
         national='Fri Mar 04 13:55:01 PST 2016',
         national_date='03/04/16',
         national_time='13:55:01',
         rfc2822='Fri, 04 Mar 2016 13:55:01 -0800',
         seconds='01',
         tz='PST',
         tz_offset='-0800',
         week_number_mon='09',
         week_number_sun='09',
         weekday='Friday',
         year='2016',
         yy='16',
         yymm='1603',
         yymmdd='160304',
         yyyy='2016',
         yyyy_mm_dd='2016/03/04',
         yyyymm='201603',
         yyyymmdd='20160304',
     )
     self.assertEqual(kron._cli(self._args(a, t, f)), kron._json(w))
示例#16
0
 def test_cli_search_timezone_partial_lower(self):
     h = kron._cli(['-s', 'madrid'])
     w = 'Europe/Madrid'
     self.assertEqual(h, w)
示例#17
0
 def test_cli8(self):
     """version"""
     w = kron.__version__
     self.assertEqual(kron._cli(['-V']), w)
     self.assertEqual(kron._cli(['--version']), w)
示例#18
0
 def test_cli8(self):
     """version"""
     w = kron.__version__
     self.assertEqual(kron._cli(['-V']), w)
     self.assertEqual(kron._cli(['--version']), w)
示例#19
0
 def test_cli_search_timezone_partial_lower(self):
     h = kron._cli(['-s', 'madrid'])
     w = 'Europe/Madrid'
     self.assertEqual(h, w)
示例#20
0
 def test_cli_search_timezone_multiple(self):
     h = kron._cli(['-s', 'mad'])
     w = '\n'.join(['Atlantic/Madeira', 'Europe/Madrid'])
     self.assertEqual(h, w)
示例#21
0
 def test_cli_search_timezone(self):
     h = kron._cli(['-s', ''])
     w = '\n'.join(pytz.all_timezones)
     self.assertEqual(h, w)
示例#22
0
 def test_timestamp_pseudo_format_all(self):
     a = '1457128501'
     h = kron.timestamp(a)
     w = {a:dict(UTC=dict(
         HH='21',
         HHMM='2155',
         HHMMSS='215501',
         HH_MM='21:55',
         HH_MM_SS='21:55:01',
         MM='55',
         SS='01',
         abbr_date='Fri, Mar 04, 2016',
         abbr_month='Mar',
         abbr_weekday='Fri',
         ampm='PM',
         base='2016-03-04 21:55:01',
         basetz='2016-03-04 21:55:01 UTC',
         ccyy='2016',
         ccyymm='201603',
         ccyymmdd='20160304',
         date='Friday, March 04, 2016',
         dd='04',
         hh='09',
         hh_MM='09:55',
         hh_MM_SS='09:55:01',
         hh_MM_SS_ampm='09:55:01 PM',
         hh_MM_ampm='09:55 PM',
         hours='21',
         hours12='09',
         hours24='21',
         iso8601='2016-03-04T21:55:01Z',
         julian='064',
         microseconds='000000',
         minutes='55',
         mm='03',
         mm_dd_yy='03/04/16',
         mmdd='0304',
         mon='Mar',
         month='March',
         national='Fri Mar 04 21:55:01 UTC 2016',
         national_date='03/04/16',
         national_time='21:55:01',
         rfc2822='Fri, 04 Mar 2016 21:55:01 +0000',
         rfc2822_='Fri, 04 Mar 2016 21:55:01',
         seconds='01',
         tz='UTC',
         tz_offset='+0000',
         week_number_mon='09',
         week_number_sun='09',
         weekday='Friday',
         year='2016',
         yy='16',
         yymm='1603',
         yymmdd='160304',
         yyyy='2016',
         yyyy_mm_dd='2016/03/04',
         yyyymm='201603',
         yyyymmdd='20160304',
     ))}
     self.maxDiff = None
     self.assertEqual(h.dict('UTC', 'all'), w[a])
     self.assertEqual(kron._cli(['-t', 'UTC', '-f', 'all', a]), \
         kron._json(w))
示例#23
0
 def test_cli_search_timezone_multiple(self):
     h = kron._cli(['-s', 'mad'])
     w = '\n'.join(['Atlantic/Madeira', 'Europe/Madrid'])
     self.assertEqual(h, w)
示例#24
0
 def test_timestamp_pseudo_format_all(self):
     a = '1457128501'
     h = kron.timestamp(a)
     w = {
         a:
         dict(UTC=dict(
             HH='21',
             HHMM='2155',
             HHMMSS='215501',
             HH_MM='21:55',
             HH_MM_SS='21:55:01',
             MM='55',
             SS='01',
             abbr_date='Fri, Mar 04, 2016',
             abbr_month='Mar',
             abbr_weekday='Fri',
             ampm='PM',
             base='2016-03-04 21:55:01',
             basetz='2016-03-04 21:55:01 UTC',
             ccyy='2016',
             ccyymm='201603',
             ccyymmdd='20160304',
             date='Friday, March 04, 2016',
             dd='04',
             hh='09',
             hh_MM='09:55',
             hh_MM_SS='09:55:01',
             hh_MM_SS_ampm='09:55:01 PM',
             hh_MM_ampm='09:55 PM',
             hours='21',
             hours12='09',
             hours24='21',
             iso8601='2016-03-04T21:55:01Z',
             julian='064',
             microseconds='000000',
             minutes='55',
             mm='03',
             mm_dd_yy='03/04/16',
             mmdd='0304',
             mon='Mar',
             month='March',
             national='Fri Mar 04 21:55:01 UTC 2016',
             national_date='03/04/16',
             national_time='21:55:01',
             rfc2822='Fri, 04 Mar 2016 21:55:01 +0000',
             rfc2822_='Fri, 04 Mar 2016 21:55:01',
             seconds='01',
             tz='UTC',
             tz_offset='+0000',
             week_number_mon='09',
             week_number_sun='09',
             weekday='Friday',
             year='2016',
             yy='16',
             yymm='1603',
             yymmdd='160304',
             yyyy='2016',
             yyyy_mm_dd='2016/03/04',
             yyyymm='201603',
             yyyymmdd='20160304',
         ))
     }
     self.maxDiff = None
     self.assertEqual(h.dict('UTC', 'all'), w[a])
     self.assertEqual(kron._cli(['-t', 'UTC', '-f', 'all', a]), \
         kron._json(w))