def test_sync_with_failed_last_update(self): """Test corpus sync when failed to get last update info from gcs.""" corpus = fuzz_task.GcsCorpus('parent', 'child', '/dir', '/dir1') utils.write_data_to_file(time.time(), '/dir1/.child_sync') self.mock.last_updated.return_value = None self.assertTrue(corpus.sync_from_gcs()) self.assertEqual(1, self.mock.rsync_to_disk.call_count)
def test_no_sync(self): """Test no corpus sync when bundle is not updated since last sync.""" corpus = fuzz_task.GcsCorpus('parent', 'child', '/dir', '/dir1') utils.write_data_to_file(time.time(), '/dir1/.child_sync') self.mock.last_updated.return_value = ( datetime.datetime.utcnow() - datetime.timedelta(days=1)) self.assertTrue(corpus.sync_from_gcs()) self.assertEqual(0, self.mock.rsync_to_disk.call_count)
def test_sync(self): """Test corpus sync.""" corpus = fuzz_task.GcsCorpus('parent', 'child', '/dir', '/dir1') self.mock.rsync_to_disk.side_effect = self._write_corpus_files self.assertTrue(corpus.sync_from_gcs()) self.assertTrue(os.path.exists('/dir1/.child_sync')) self.assertEqual(('/dir',), self.mock.rsync_to_disk.call_args[0][1:]) self.fs.CreateFile('/dir/c') self.assertListEqual(['/dir/c'], corpus.get_new_files()) corpus.upload_files(corpus.get_new_files()) self.assertEqual((['/dir/c'],), self.mock.upload_files.call_args[0][1:]) self.assertListEqual([], corpus.get_new_files())