Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/test_archiver.py
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | def archive_present_content(self): | ||||
# After the run, the content should NOT be in the archive.* | # After the run, the content should NOT be in the archive.* | ||||
self.archiver.run() | self.archiver.run() | ||||
with self.assertRaises(ObjNotFoundError): | with self.assertRaises(ObjNotFoundError): | ||||
self.remote_objstorage.content_get(id) | self.remote_objstorage.content_get(id) | ||||
@istest | @istest | ||||
def archive_ongoing_remaining(self): | def archive_ongoing_remaining(self): | ||||
""" A content that is ongoing and still have some time | """ A content that is ongoing and still have some time | ||||
to be archived should not be rescheduled. | to be archived should not be rescheduled. | ||||
ardumont: 'enough '
Ctrl-t just before the h in emacs will transpose the blank character and the t ^^ | |||||
""" | """ | ||||
id = self.__add_content(b'archive_ongoing_remaining', status='ongoing') | id = self.__add_content(b'archive_ongoing_remaining', status='ongoing') | ||||
items = [x for batch in self.archiver.get_unarchived_content() | items = [x for batch in self.archiver.get_unarchived_content() | ||||
for x in batch] | for x in batch] | ||||
id = r'\x' + hashutil.hash_to_hex(id) | id = r'\x' + hashutil.hash_to_hex(id) | ||||
self.assertNotIn(id, items) | self.assertNotIn(id, items) | ||||
@istest | @istest | ||||
def archive_ongoing_elapsed(self): | def archive_ongoing_elapsed(self): | ||||
""" A content that is ongoing but with elapsed time should | """ A content that is ongoing but with elapsed time should | ||||
be rescheduled. | be rescheduled. | ||||
""" | """ | ||||
# Create an ongoing archive content with time elapsed by 1s. | # Create an ongoing archive content with time elapsed by 1s. | ||||
id = self.__add_content( | id = self.__add_content( | ||||
b'archive_ongoing_elapsed', | b'archive_ongoing_elapsed', | ||||
status='ongoing', | status='ongoing', | ||||
date="'%s'" % (datetime.now() - timedelta( | date="'%s'" % (datetime.now() - timedelta( | ||||
seconds=self.archiver.archival_max_age + 1 | seconds=self.archiver.config['archival_max_age'] + 1 | ||||
)) | )) | ||||
) | ) | ||||
items = [x for batch in self.archiver.get_unarchived_content() | items = [x for batch in self.archiver.get_unarchived_content() | ||||
for x in batch] | for x in batch] | ||||
id = r'\x' + hashutil.hash_to_hex(id) | id = r'\x' + hashutil.hash_to_hex(id) | ||||
self.assertIn(id, items) | self.assertIn(id, items) | ||||
@istest | @istest | ||||
Show All 9 Lines |
'enough '
Ctrl-t just before the h in emacs will transpose the blank character and the t ^^