Esempio n. 1
0
 def maybe_start_download(self):
     """Check the time the last image refresh happened and initiate a new
     one if older than 15 minutes.
     """
     last_modified = tftppath.maas_meta_last_modified(self.tftp_root)
     if last_modified is None:
         yield self._start_download()
     else:
         age_in_seconds = self.clock.seconds() - last_modified
         if age_in_seconds >= timedelta(minutes=15).total_seconds():
             yield self._start_download()
Esempio n. 2
0
 def test_maas_meta_last_modified_returns_None_if_no_file(self):
     observed = maas_meta_last_modified(
         os.path.join(self.tftproot, "maas.meta"))
     self.assertIsNone(observed)
Esempio n. 3
0
 def test_maas_meta_last_modified_returns_modification_time(self):
     path = factory.make_file(self.tftproot, name="maas.meta")
     expected = os.path.getmtime(path)
     observed = maas_meta_last_modified(self.tftproot)
     self.assertEqual(expected, observed)