183
175
self.gpg_handler.importKeyringFile(ring)
184
176
self.assertEqual(self.gpg_handler.checkTrustDb(), 0)
186
def testHomeDirectoryJob(self):
187
"""Does the job to touch the home work."""
188
gpghandler = getUtility(IGPGHandler)
189
naked_gpghandler = removeSecurityProxy(gpghandler)
191
# Get a list of all the files in the home directory.
192
files_to_check = [os.path.join(naked_gpghandler.home, f)
193
for f in os.listdir(naked_gpghandler.home)]
194
files_to_check.append(naked_gpghandler.home)
195
self.assertTrue(len(files_to_check) > 1)
197
# Set the last modified times to 12 hours ago
198
nowless12 = (datetime.now(UTC) - timedelta(hours=12)).utctimetuple()
199
lm_time = timegm(nowless12)
200
for fname in files_to_check:
201
os.utime(fname, (lm_time, lm_time))
203
# Touch the files and re-check the last modified times.
204
gpghandler.touchConfigurationDirectory()
205
second_last_modified_times = dict(
206
(fname, os.path.getmtime(fname)) for fname in files_to_check)
207
for fname in files_to_check:
209
lm_time + 12 * 3600 <= second_last_modified_times[fname])
180
return unittest.TestLoader().loadTestsFromName(__name__)
183
if __name__ == "__main__":
184
unittest.main(defaultTest=test_suite())