Exemple #1
0
    def test_dirs_in_period(self):
        mart = TestHelper.random_name()
        date1 = Date.tz_berlin(2014,4,1)
        date2 = Date.tz_berlin(2014,4,2)
        TestHelper.mkdir('/tmp/' + mart)
        TestHelper.mkdir('/tmp/' + mart + '/' + str(date1.seconds()))

        dirs = self.fs.dirs_of_period(mart, '',  date1.seconds(), date2.seconds())
        self.assertEqual(['/tmp/' + mart + '/' + str(date1.seconds())], dirs)
Exemple #2
0
    def test_dirs_in_period(self):
        mart = TestHelper.random_name()
        date1 = Date.tz_berlin(2014, 4, 1)
        date2 = Date.tz_berlin(2014, 4, 2)
        TestHelper.mkdir('/tmp/' + mart)
        TestHelper.mkdir('/tmp/' + mart + '/' + str(date1.seconds()))

        dirs = self.fs.dirs_of_period(mart, '', date1.seconds(),
                                      date2.seconds())
        self.assertEqual(['/tmp/' + mart + '/' + str(date1.seconds())], dirs)
Exemple #3
0
 def test_tz_berlin(self):
     d = Date.tz_berlin(2014, 4, 2)
     self.assertEqual(2014, d.datetime().year)
     self.assertEqual(4, d.datetime().month)
     self.assertEqual(2, d.datetime().day)
     d2 = pytz.timezone('Europe/Berlin').localize(datetime(2014, 4, 2))
     self.assertEqual(d2, d.datetime())
Exemple #4
0
 def test_tz_berlin(self):
     d = Date.tz_berlin(2014,4,2)
     self.assertEqual(2014, d.datetime().year)
     self.assertEqual(4, d.datetime().month)
     self.assertEqual(2, d.datetime().day)
     d2 = pytz.timezone('Europe/Berlin').localize(datetime(2014,4,2))
     self.assertEqual(d2, d.datetime())
Exemple #5
0
 def test_seconds_with_tzinfo(self):
     d = Date(timezone=pytz.timezone('Europe/Berlin'))
     d.parse('19700101')
     self.assertEqual(-3600, d.seconds())
Exemple #6
0
 def test_seconds_from_start_epoch(self):
     d = Date(timezone=pytz.utc)
     d.parse('19700101')
     self.assertEqual(0, d.seconds())
Exemple #7
0
 def test_parse(self):
     d = Date(timezone=pytz.timezone('Europe/Berlin'))
     dt = d.parse('20140402').datetime()
     self.assertEqual(dt.year,  2014)
     self.assertEqual(dt.month, 04)
     self.assertEqual(dt.day,   02)
Exemple #8
0
 def test_localize_case3(self):
     d = Date()
     with self.assertRaises(Exception):
         d.localize(datetime(2014,04,01))
Exemple #9
0
 def test_localize_case2(self):
     d = Date(timezone=pytz.utc, date=datetime(2014,04,01))
     self.assertEqual(pytz.utc, d.datetime().tzinfo)
Exemple #10
0
 def test_construct_w_date_wo_tzinfo(self):
     d = Date(timezone=pytz.utc, date=datetime(2014,04,01))
     assert d.datetime().tzinfo is not None
Exemple #11
0
 def test_localize_case0(self):
     d = Date()
     assert (d is not None) and (d._datetime is None)
Exemple #12
0
 def test_localize_case1(self):
     d = Date(date=datetime(2014, 04, 01, tzinfo=pytz.utc))
Exemple #13
0
 def test_seconds_with_tzinfo(self):
     d = Date(timezone=pytz.timezone('Europe/Berlin'))
     d.parse('19700101')
     self.assertEqual(-3600, d.seconds())
Exemple #14
0
 def test_seconds_from_start_epoch(self):
     d = Date(timezone=pytz.utc)
     d.parse('19700101')
     self.assertEqual(0, d.seconds())
Exemple #15
0
 def test_parse(self):
     d = Date(timezone=pytz.timezone('Europe/Berlin'))
     dt = d.parse('20140402').datetime()
     self.assertEqual(dt.year, 2014)
     self.assertEqual(dt.month, 04)
     self.assertEqual(dt.day, 02)
Exemple #16
0
 def test_localize_case3(self):
     d = Date()
     with self.assertRaises(Exception):
         d.localize(datetime(2014, 04, 01))
Exemple #17
0
 def test_localize_case2(self):
     d = Date(timezone=pytz.utc, date=datetime(2014, 04, 01))
     self.assertEqual(pytz.utc, d.datetime().tzinfo)
Exemple #18
0
 def test_from_utime(self):
     utime = Date.tz_berlin(2014,3,1).seconds()
     d = Date.from_utc_utime(pytz.timezone('Europe/Berlin'), utime)
     self.assertEqual(utime, d.seconds())
Exemple #19
0
 def test_from_utime(self):
     utime = Date.tz_berlin(2014, 3, 1).seconds()
     d = Date.from_utc_utime(pytz.timezone('Europe/Berlin'), utime)
     self.assertEqual(utime, d.seconds())
Exemple #20
0
 def test_construct_w_timezone(self):
     d = Date(timezone=pytz.utc)
     assert d.timezone is not None
Exemple #21
0
 def test_construct_w_date_wo_tzinfo(self):
     d = Date(timezone=pytz.utc, date=datetime(2014, 04, 01))
     assert d.datetime().tzinfo is not None