def test_sync_last_modified(self, now_mock, upload_chunked_mock, get_backup_directory_mock):
""" Test whether syncs are skipped when file was not modified. """
now_mock.return_value = timezone.make_aware(timezone.datetime(2016, 1, 1))
dropbox_settings = DropboxSettings.get_solo()
dropbox_settings.latest_sync = timezone.now() - timezone.timedelta(weeks=1)
dropbox_settings.save()
with tempfile.TemporaryDirectory() as temp_dir:
get_backup_directory_mock.return_value = temp_dir
temp_file = tempfile.NamedTemporaryFile(dir=temp_dir, delete=False)
temp_file.write(b'Meh.')
temp_file.flush()
# 1420070400: 01 Jan 2015 00:00:00 GMT
os.utime(temp_file.name, times=(1420070400, 1420070400))
self.assertFalse(upload_chunked_mock.called)
# File should be ignored, as it's modification timestamp is before latest sync.
dsmr_backup.services.dropbox.sync()
self.assertFalse(upload_chunked_mock.called)
评论列表
文章目录