コード例 #1
0
 def testMissingArchiveDataFile(self):
     story_set = test_stories.DummyStorySet(['story'])
     with self.assertRaises(story_runner.ArchiveError):
         story_runner._UpdateAndCheckArchives(story_set.archive_data_file,
                                              story_set.wpr_archive_info,
                                              story_set.stories,
                                              self._mock_story_filter)
コード例 #2
0
 def testArchiveDataFileDoesNotExist(self):
   story_set = test_stories.DummyStorySet(
       ['story'], archive_data_file='does_not_exist.json')
   with self.assertRaises(story_runner.ArchiveError):
     story_runner._UpdateAndCheckArchives(
         story_set.archive_data_file, story_set.wpr_archive_info,
         story_set.stories, self._mock_story_filter)
コード例 #3
0
 def testArchiveWithMissingStory(self):
   # This test file has a recording for a 'http://www.testurl.com' story only.
   archive_data_file = os.path.join(
       util.GetUnittestDataDir(), 'archive_files', 'test.json')
   story_set = test_stories.DummyStorySet(
       ['http://www.testurl.com', 'http://www.google.com'],
       archive_data_file=archive_data_file)
   with self.assertRaises(story_runner.ArchiveError):
     story_runner._UpdateAndCheckArchives(
         story_set.archive_data_file, story_set.wpr_archive_info,
         story_set.stories, self._mock_story_filter)
コード例 #4
0
 def testArchiveWithMissingWprFile(self):
   # This test file claims to have recordings for both
   # 'http://www.testurl.com' and 'http://www.google.com'; but the file with
   # the wpr recording for the later story is actually missing.
   archive_data_file = os.path.join(
       util.GetUnittestDataDir(), 'archive_files',
       'test_missing_wpr_file.json')
   story_set = test_stories.DummyStorySet(
       ['http://www.testurl.com', 'http://www.google.com'],
       archive_data_file=archive_data_file)
   with self.assertRaises(story_runner.ArchiveError):
     story_runner._UpdateAndCheckArchives(
         story_set.archive_data_file, story_set.wpr_archive_info,
         story_set.stories, self._mock_story_filter)
コード例 #5
0
 def testMissingArchiveDataFileWithSkippedStory(self):
     story_set = test_stories.DummyStorySet(['story'])
     self._mock_story_filter.ShouldSkip.return_value = True
     success = story_runner._UpdateAndCheckArchives(
         story_set.archive_data_file, story_set.wpr_archive_info,
         story_set.stories, self._mock_story_filter)
     self.assertTrue(success)
コード例 #6
0
 def testUpdateAndCheckArchivesSuccess(self):
     # This test file has a recording for a 'http://www.testurl.com' story only.
     archive_data_file = os.path.join(util.GetUnittestDataDir(),
                                      'archive_files', 'test.json')
     story_set = test_stories.DummyStorySet(
         ['http://www.testurl.com'], archive_data_file=archive_data_file)
     success = story_runner._UpdateAndCheckArchives(
         story_set.archive_data_file, story_set.wpr_archive_info,
         story_set.stories, self._mock_story_filter)
     self.assertTrue(success)
コード例 #7
0
  def testUpdateAndCheckArchives(self):
    usr_stub = system_stub.Override(story_runner, ['cloud_storage'])
    wpr_stub = system_stub.Override(archive_info, ['cloud_storage'])
    try:
      uss = user_story_set.UserStorySet()
      uss.AddUserStory(page_module.Page(
          'http://www.testurl.com', uss, uss.base_dir))
      # Page set missing archive_data_file.
      self.assertRaises(
          story_runner.ArchiveError,
          story_runner._UpdateAndCheckArchives,
          uss.archive_data_file, uss.wpr_archive_info, uss.user_stories)

      uss = user_story_set.UserStorySet(
          archive_data_file='missing_archive_data_file.json')
      uss.AddUserStory(page_module.Page(
          'http://www.testurl.com', uss, uss.base_dir))
      # Page set missing json file specified in archive_data_file.
      self.assertRaises(
          story_runner.ArchiveError,
          story_runner._UpdateAndCheckArchives,
          uss.archive_data_file, uss.wpr_archive_info, uss.user_stories)

      uss = user_story_set.UserStorySet(
          archive_data_file='../../unittest_data/archive_files/test.json',
          cloud_storage_bucket=cloud_storage.PUBLIC_BUCKET)
      uss.AddUserStory(page_module.Page(
          'http://www.testurl.com', uss, uss.base_dir))
      # Page set with valid archive_data_file.
      self.assertTrue(story_runner._UpdateAndCheckArchives(
          uss.archive_data_file, uss.wpr_archive_info, uss.user_stories))
      uss.AddUserStory(page_module.Page(
          'http://www.google.com', uss, uss.base_dir))
      # Page set with an archive_data_file which exists but is missing a page.
      self.assertRaises(
          story_runner.ArchiveError,
          story_runner._UpdateAndCheckArchives,
          uss.archive_data_file, uss.wpr_archive_info, uss.user_stories)

      uss = user_story_set.UserStorySet(
          archive_data_file='../../unittest_data/test_missing_wpr_file.json',
          cloud_storage_bucket=cloud_storage.PUBLIC_BUCKET)
      uss.AddUserStory(page_module.Page(
          'http://www.testurl.com', uss, uss.base_dir))
      uss.AddUserStory(page_module.Page(
          'http://www.google.com', uss, uss.base_dir))
      # Page set with an archive_data_file which exists and contains all pages
      # but fails to find a wpr file.
      self.assertRaises(
          story_runner.ArchiveError,
          story_runner._UpdateAndCheckArchives,
          uss.archive_data_file, uss.wpr_archive_info, uss.user_stories)
    finally:
      usr_stub.Restore()
      wpr_stub.Restore()
コード例 #8
0
  def testUpdateAndCheckArchives(self):
    usr_stub = system_stub.Override(story_runner, ['cloud_storage'])
    wpr_stub = system_stub.Override(archive_info, ['cloud_storage'])
    archive_data_dir = os.path.join(
        util.GetTelemetryDir(),
        'telemetry', 'internal', 'testing', 'archive_files')
    try:
      story_set = story_module.StorySet()
      story_set.AddStory(page_module.Page(
          'http://www.testurl.com', story_set, story_set.base_dir))
      # Page set missing archive_data_file.
      self.assertRaises(
          story_runner.ArchiveError,
          story_runner._UpdateAndCheckArchives,
          story_set.archive_data_file,
          story_set.wpr_archive_info,
          story_set.stories)

      story_set = story_module.StorySet(
          archive_data_file='missing_archive_data_file.json')
      story_set.AddStory(page_module.Page(
          'http://www.testurl.com', story_set, story_set.base_dir))
      # Page set missing json file specified in archive_data_file.
      self.assertRaises(
          story_runner.ArchiveError,
          story_runner._UpdateAndCheckArchives,
          story_set.archive_data_file,
          story_set.wpr_archive_info,
          story_set.stories)

      story_set = story_module.StorySet(
          archive_data_file=os.path.join(archive_data_dir, 'test.json'),
          cloud_storage_bucket=cloud_storage.PUBLIC_BUCKET)
      story_set.AddStory(page_module.Page(
          'http://www.testurl.com', story_set, story_set.base_dir))
      # Page set with valid archive_data_file.
      self.assertTrue(story_runner._UpdateAndCheckArchives(
            story_set.archive_data_file, story_set.wpr_archive_info,
            story_set.stories))
      story_set.AddStory(page_module.Page(
          'http://www.google.com', story_set, story_set.base_dir))
      # Page set with an archive_data_file which exists but is missing a page.
      self.assertRaises(
          story_runner.ArchiveError,
          story_runner._UpdateAndCheckArchives,
          story_set.archive_data_file,
          story_set.wpr_archive_info,
          story_set.stories)

      story_set = story_module.StorySet(
          archive_data_file=
              os.path.join(archive_data_dir, 'test_missing_wpr_file.json'),
          cloud_storage_bucket=cloud_storage.PUBLIC_BUCKET)
      story_set.AddStory(page_module.Page(
          'http://www.testurl.com', story_set, story_set.base_dir))
      story_set.AddStory(page_module.Page(
          'http://www.google.com', story_set, story_set.base_dir))
      # Page set with an archive_data_file which exists and contains all pages
      # but fails to find a wpr file.
      self.assertRaises(
          story_runner.ArchiveError,
          story_runner._UpdateAndCheckArchives,
          story_set.archive_data_file,
          story_set.wpr_archive_info,
          story_set.stories)
    finally:
      usr_stub.Restore()
      wpr_stub.Restore()
コード例 #9
0
    def testUpdateAndCheckArchives(self):
        usr_stub = system_stub.Override(story_runner, ['cloud_storage'])
        wpr_stub = system_stub.Override(archive_info, ['cloud_storage'])
        archive_data_dir = os.path.join(util.GetTelemetryDir(), 'telemetry',
                                        'internal', 'testing', 'archive_files')
        try:
            story_set = story_module.StorySet()
            story_set.AddStory(
                page_module.Page('http://www.testurl.com', story_set,
                                 story_set.base_dir))
            # Page set missing archive_data_file.
            self.assertRaises(story_runner.ArchiveError,
                              story_runner._UpdateAndCheckArchives,
                              story_set.archive_data_file,
                              story_set.wpr_archive_info, story_set.stories)

            story_set = story_module.StorySet(
                archive_data_file='missing_archive_data_file.json')
            story_set.AddStory(
                page_module.Page('http://www.testurl.com', story_set,
                                 story_set.base_dir))
            # Page set missing json file specified in archive_data_file.
            self.assertRaises(story_runner.ArchiveError,
                              story_runner._UpdateAndCheckArchives,
                              story_set.archive_data_file,
                              story_set.wpr_archive_info, story_set.stories)

            story_set = story_module.StorySet(
                archive_data_file=os.path.join(archive_data_dir, 'test.json'),
                cloud_storage_bucket=cloud_storage.PUBLIC_BUCKET)
            story_set.AddStory(
                page_module.Page('http://www.testurl.com', story_set,
                                 story_set.base_dir))
            # Page set with valid archive_data_file.
            self.assertTrue(
                story_runner._UpdateAndCheckArchives(
                    story_set.archive_data_file, story_set.wpr_archive_info,
                    story_set.stories))
            story_set.AddStory(
                page_module.Page('http://www.google.com', story_set,
                                 story_set.base_dir))
            # Page set with an archive_data_file which exists but is missing a page.
            self.assertRaises(story_runner.ArchiveError,
                              story_runner._UpdateAndCheckArchives,
                              story_set.archive_data_file,
                              story_set.wpr_archive_info, story_set.stories)

            story_set = story_module.StorySet(
                archive_data_file=os.path.join(archive_data_dir,
                                               'test_missing_wpr_file.json'),
                cloud_storage_bucket=cloud_storage.PUBLIC_BUCKET)
            story_set.AddStory(
                page_module.Page('http://www.testurl.com', story_set,
                                 story_set.base_dir))
            story_set.AddStory(
                page_module.Page('http://www.google.com', story_set,
                                 story_set.base_dir))
            # Page set with an archive_data_file which exists and contains all pages
            # but fails to find a wpr file.
            self.assertRaises(story_runner.ArchiveError,
                              story_runner._UpdateAndCheckArchives,
                              story_set.archive_data_file,
                              story_set.wpr_archive_info, story_set.stories)
        finally:
            usr_stub.Restore()
            wpr_stub.Restore()