Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(943)

Unified Diff: tools/telemetry/telemetry/wpr/archive_info_unittest.py

Issue 834173006: [Telemetry] Fix WPR files not being downloaded when required. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove useless check. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/wpr/archive_info_unittest.py
diff --git a/tools/telemetry/telemetry/wpr/archive_info_unittest.py b/tools/telemetry/telemetry/wpr/archive_info_unittest.py
index 0916f0953094c2977291ccccd1f6a7bb6acc0665..32b7697bdfd82e9b1cc69c2a2ded1c39690fc3bd 100644
--- a/tools/telemetry/telemetry/wpr/archive_info_unittest.py
+++ b/tools/telemetry/telemetry/wpr/archive_info_unittest.py
@@ -8,6 +8,7 @@ import tempfile
import unittest
from telemetry.page import page
+from telemetry.unittest_util import system_stub
from telemetry.util import cloud_storage
from telemetry.wpr import archive_info
@@ -35,6 +36,7 @@ archive_info_contents = ("""
class WprArchiveInfoTest(unittest.TestCase):
def setUp(self):
+ self._overrides = system_stub.Override(archive_info, ['cloud_storage'])
self.tmp_dir = tempfile.mkdtemp()
# Write the metadata.
self.user_story_set_archive_info_file = os.path.join(
@@ -53,12 +55,26 @@ class WprArchiveInfoTest(unittest.TestCase):
def tearDown(self):
shutil.rmtree(self.tmp_dir)
+ self._overrides.Restore()
def assertCorrectHashFile(self, file_path):
self.assertTrue(os.path.exists(file_path + '.sha1'))
with open(file_path + '.sha1', 'rb') as f:
self.assertEquals(cloud_storage.CalculateHash(file_path), f.read())
+ def testDownloadArchivesIfNeeded(self):
+ cloud_storage_stub = self._overrides.cloud_storage
+ # Second hash doesn't match, need to fetch it.
+ cloud_storage_stub.SetRemotePathsForTesting(
+ {cloud_storage.PUBLIC_BUCKET: {recording1: "dummyhash",
+ recording2: "dummyhash22"}})
+ cloud_storage_stub.SetCalculatedHashesForTesting(
+ {os.path.join(self.tmp_dir, recording1): "dummyhash",
+ os.path.join(self.tmp_dir, recording2): "dummyhash2",})
+ self.archive_info.DownloadArchivesIfNeeded()
+ self.assertEquals(len(cloud_storage_stub.downloaded_files), 1)
+ self.assertEquals(cloud_storage_stub.downloaded_files[0], recording2)
+
def testReadingArchiveInfo(self):
self.assertIsNotNone(self.archive_info.WprFilePathForUserStory(page1))
self.assertEquals(recording1, os.path.basename(

Powered by Google App Engine
This is Rietveld 408576698