Esempio n. 1
0
 def test_hourly_and_daily(self):
     files = [
         store.LogFile('bar', date=datetime.date(2015, 5, 20)),
         store.LogFile('bar', dt=datetime.datetime(2015, 5, 21, 20)),
         store.LogFile('bar',
                       dt=datetime.datetime.utcnow().replace(minute=0,
                                                             second=0))
     ]
     out_files = store.filter_log_files_for_active(files)
     assert_equal(len(out_files), 2)
Esempio n. 2
0
    def test_hourly(self):
        now_hourly = datetime.datetime.utcnow().replace(minute=0, second=0)

        files = [
            store.LogFile('bar', dt=now_hourly - datetime.timedelta(hours=1)),
            store.LogFile('bar', dt=now_hourly)
        ]
        out_files = store.filter_log_files_for_active(files)
        assert_equal(len(out_files), 1)
        assert_equal(out_files[0], files[0])
Esempio n. 3
0
 def test_only_yesterday(self):
     files = [
         store.LogFile('foo', date=datetime.date.today()),
         store.LogFile('bar', date=datetime.date.today()),
         store.LogFile('bar',
                       date=datetime.date.today() -
                       datetime.timedelta(days=1))
     ]
     out_files = store.filter_log_files_for_active(files)
     assert_equal(len(out_files), 1)
     assert_equal(out_files[0], files[-1])
Esempio n. 4
0
 def test_dt_zipped(self):
     dt = datetime.datetime(2015, 5, 21, 20)
     lf = store.LogFile("foo", dt=dt, bzip=True)
     assert_equal(lf.file_path, "20150521/foo-2015052120.log.bz2")
Esempio n. 5
0
 def test_dt_host(self):
     dt = datetime.datetime(2015, 5, 21, 20)
     lf = store.LogFile("foo", dt=dt, host='localhost')
     assert_equal(lf.file_path, "20150521/foo-2015052120-localhost.log")
Esempio n. 6
0
 def test_simple_dt(self):
     dt = datetime.datetime(2015, 5, 21, 20)
     lf = store.LogFile("foo", dt=dt)
     assert_equal(lf.file_path, "20150521/foo-2015052120.log")
Esempio n. 7
0
 def test_simple_date(self):
     date = datetime.date(2015, 5, 21)
     lf = store.LogFile("foo", date=date)
     assert_equal(lf.file_path, "20150521/foo-20150521.log")
Esempio n. 8
0
 def test_any(self):
     date = (datetime.datetime.utcnow() - datetime.timedelta(days=2)).date()
     files = [store.LogFile('foo', date=date, bzip=False)]
     out_files = store.filter_log_files_for_uploading(files, False)
     assert_equal(len(out_files), 1)
Esempio n. 9
0
 def test_no_zipped(self):
     date = (datetime.datetime.utcnow() - datetime.timedelta(days=2)).date()
     files = [store.LogFile('foo', date=date, bzip=True)]
     out_files = store.filter_log_files_for_zipping(files)
     assert_equal(len(out_files), 0)
Esempio n. 10
0
 def test_leave_active(self):
     files = [store.LogFile('foo', date=datetime.date.today())]
     out_files = store.filter_log_files_for_active(files)
     assert_equal(len(out_files), 0)