Example #1
0
 def test_touch(self):
     datefile = Datefile('/tmp', TEST_FILE)
     actual = datefile.timestamp
     after = datetime.utcnow()
     datefile.touch()
     ok_(datefile.timestamp > actual)
     ok_(actual < after)
Example #2
0
 def test_is_older_than(self):
     self.delete()
     before = datetime.utcnow()
     datefile = Datefile('/tmp', TEST_FILE)
     ok_(datefile.is_older_than({'seconds': 2}))
     ok_(datefile.is_older_than({'days': 2}))
     # test will stop working on Jan 1, 2170
     ok_(not datefile.is_older_than({'days': 73000}))
     datefile.touch(before)
     time.sleep(3)
     ok_(datefile.is_older_than({'seconds': 2}))
     ok_(not datefile.is_older_than({'minutes': 5}))