Esempio n. 1
0
    def test_selects_newest_matching(self):
        """If multiple files match, the newest written should be used."""
        lease_d = self.tmp_dir()
        valid_1 = "dhclient.leases"
        valid_2 = "dhclient.lease"
        valid_1_path = self.tmp_path(valid_1, lease_d)
        valid_2_path = self.tmp_path(valid_2, lease_d)

        self._populate_dir_list(lease_d, [valid_1, valid_2])
        self.assertEqual(valid_2_path, get_latest_lease(lease_d))

        # now update mtime on valid_2 to be older than valid_1 and re-check.
        mtime = int(os.path.getmtime(valid_1_path)) - 1
        os.utime(valid_2_path, (mtime, mtime))

        self.assertEqual(valid_1_path, get_latest_lease(lease_d))
Esempio n. 2
0
    def test_selects_newest_matching(self):
        """If multiple files match, the newest written should be used."""
        lease_d = self.tmp_dir()
        valid_1 = "dhclient.leases"
        valid_2 = "dhclient.lease"
        valid_1_path = self.tmp_path(valid_1, lease_d)
        valid_2_path = self.tmp_path(valid_2, lease_d)

        self._populate_dir_list(lease_d, [valid_1, valid_2])
        self.assertEqual(valid_2_path, get_latest_lease(lease_d))

        # now update mtime on valid_2 to be older than valid_1 and re-check.
        mtime = int(os.path.getmtime(valid_1_path)) - 1
        os.utime(valid_2_path, (mtime, mtime))

        self.assertEqual(valid_1_path, get_latest_lease(lease_d))
Esempio n. 3
0
 def _pop_and_test(self, files, expected):
     lease_d = self.tmp_dir()
     self._populate_dir_list(lease_d, files)
     self.assertEqual(self.tmp_path(expected, lease_d),
                      get_latest_lease(lease_d))
Esempio n. 4
0
 def _pop_and_test(self, files, expected):
     lease_d = self.tmp_dir()
     self._populate_dir_list(lease_d, files)
     self.assertEqual(self.tmp_path(expected, lease_d),
                      get_latest_lease(lease_d))