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

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: Only use the CloudStorage mock in one test, as it breaks the others. 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
« no previous file with comments | « tools/telemetry/telemetry/wpr/archive_info.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9feaf7e71dd6a3c198bfcfc695a3f305362b02a1 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
@@ -59,6 +60,23 @@ class WprArchiveInfoTest(unittest.TestCase):
with open(file_path + '.sha1', 'rb') as f:
self.assertEquals(cloud_storage.CalculateHash(file_path), f.read())
+ def testDownloadArchivesIfNeeded(self):
+ overrides = system_stub.Override(archive_info, ['cloud_storage'])
+ try:
+ cloud_storage_stub = 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)
+ finally:
+ overrides.Restore()
+
def testReadingArchiveInfo(self):
self.assertIsNotNone(self.archive_info.WprFilePathForUserStory(page1))
self.assertEquals(recording1, os.path.basename(
« no previous file with comments | « tools/telemetry/telemetry/wpr/archive_info.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698