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

Unified Diff: tools/telemetry/telemetry/unittest/page_set_smoke_test.py

Issue 292443003: Add crendential smoke test for page sets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: Address comments & rebase Created 6 years, 7 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/core/browser_credentials.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/unittest/page_set_smoke_test.py
diff --git a/tools/telemetry/telemetry/unittest/page_set_smoke_test.py b/tools/telemetry/telemetry/unittest/page_set_smoke_test.py
index aa30415223b817c1e9baae8cfdefbd97c7cf6405..4c7599de7d49eb1b6a4cdd8beeb2ee9517b41c9e 100644
--- a/tools/telemetry/telemetry/unittest/page_set_smoke_test.py
+++ b/tools/telemetry/telemetry/unittest/page_set_smoke_test.py
@@ -6,6 +6,7 @@ import logging
import os
import unittest
+from telemetry.core import browser_credentials
from telemetry.core import discover
from telemetry.page import page_set as page_set_module
from telemetry.page import page_set_archive_info
@@ -13,35 +14,55 @@ from telemetry.page import page_set_archive_info
class PageSetSmokeTest(unittest.TestCase):
+ def CheckArchive(self, page_set):
+ # TODO: Eventually these should be fatal.
+ if not page_set.archive_data_file:
+ logging.warning('Skipping %s: no archive data file', page_set.file_path)
+ return
+
+ logging.info('Testing %s', page_set.file_path)
+
+ archive_data_file_path = os.path.join(page_set.base_dir,
+ page_set.archive_data_file)
+ self.assertTrue(os.path.exists(archive_data_file_path),
+ msg='Archive data file not found for %s' %
+ page_set.file_path)
+
+ wpr_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile(
+ archive_data_file_path, ignore_archive=True)
+ for page in page_set.pages:
+ if not page.url.startswith('http'):
+ continue
+ self.assertTrue(wpr_archive_info.WprFilePathForPage(page),
+ msg='No archive found for %s in %s' % (
+ page.url, page_set.archive_data_file))
+
+ def CheckCredentials(self, page_set):
+ credentials = browser_credentials.BrowserCredentials()
+ if page_set.credentials_path:
+ credentials.credentials_path = (
+ os.path.join(page_set.base_dir, page_set.credentials_path))
+ for page in page_set.pages:
+ fail_message = ('page %s of %s has invalid credentials %s' %
+ (page.url, page_set.file_path, page.credentials))
+ if page.credentials:
+ try:
+ self.assertTrue(credentials.CanLogin(page.credentials), fail_message)
+ except browser_credentials.CredentialsError:
+ self.fail(fail_message)
+
def RunSmokeTest(self, page_sets_dir):
- """
- Run smoke test on all page sets in page_sets_dir. Subclass of
- PageSetSmokeTest is supposed to call this in some test method to run smoke
- test.
+ """Run smoke test on all page sets in page_sets_dir.
+
+ Subclass of PageSetSmokeTest is supposed to call this in some test
+ method to run smoke test.
"""
# Instantiate all page sets and verify that all URLs have an associated
# archive.
page_sets = discover.GetAllPageSetFilenames(page_sets_dir)
+
for page_set_path in page_sets:
page_set = page_set_module.PageSet.FromFile(page_set_path)
-
- # TODO: Eventually these should be fatal.
- if not page_set.archive_data_file:
- logging.warning('Skipping %s: no archive data file', page_set_path)
- continue
-
- logging.info('Testing %s', page_set_path)
-
- archive_data_file_path = os.path.join(page_set.base_dir,
- page_set.archive_data_file)
- self.assertTrue(os.path.exists(archive_data_file_path),
- msg='Archive data file not found for %s' % page_set_path)
-
- wpr_archive_info = page_set_archive_info.PageSetArchiveInfo.FromFile(
- archive_data_file_path, ignore_archive=True)
- for page in page_set.pages:
- if not page.url.startswith('http'):
- continue
- self.assertTrue(wpr_archive_info.WprFilePathForPage(page),
- msg='No archive found for %s in %s' % (
- page.url, page_set.archive_data_file))
+ logging.info('Testing %s', page_set.file_path)
+ self.CheckArchive(page_set)
+ self.CheckCredentials(page_set)
« no previous file with comments | « tools/telemetry/telemetry/core/browser_credentials.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698