def testNameNone(self):
     options = MockOptions('othersuite/textures', '')
     page_filter = page_filter_module.PageFilter(options)
     self.assertTrue(page_filter.IsSelected(self.p3))
     options = MockOptions('conformance/textures', '')
     page_filter = page_filter_module.PageFilter(options)
     self.assertFalse(page_filter.IsSelected(self.p3))
 def testURLPattern(self):
     options = MockOptions('conformance/textures', '')
     page_filter = page_filter_module.PageFilter(options)
     self.assertTrue(page_filter.IsSelected(self.p1))
     self.assertFalse(page_filter.IsSelected(self.p2))
     options = MockOptions('textures', '')
     page_filter = page_filter_module.PageFilter(options)
     self.assertTrue(page_filter.IsSelected(self.p1))
     self.assertTrue(page_filter.IsSelected(self.p2))
     options = MockOptions('somethingelse', '')
     page_filter = page_filter_module.PageFilter(options)
     self.assertFalse(page_filter.IsSelected(self.p1))
     self.assertFalse(page_filter.IsSelected(self.p2))
 def testName(self):
     options = MockOptions('somethingelse', '')
     page_filter = page_filter_module.PageFilter(options)
     self.assertFalse(page_filter.IsSelected(self.p1))
     self.assertFalse(page_filter.IsSelected(self.p2))
     options = MockOptions('textures_tex_sub_image', '')
     page_filter = page_filter_module.PageFilter(options)
     self.assertTrue(page_filter.IsSelected(self.p1))
     self.assertTrue(page_filter.IsSelected(self.p2))
     options = MockOptions('WebglConformance', '')
     page_filter = page_filter_module.PageFilter(options)
     self.assertTrue(page_filter.IsSelected(self.p1))
     self.assertFalse(page_filter.IsSelected(self.p2))
     options = MockOptions('OtherSuite', '')
     page_filter = page_filter_module.PageFilter(options)
     self.assertFalse(page_filter.IsSelected(self.p1))
     self.assertTrue(page_filter.IsSelected(self.p2))
    def testLabelFilters(self):
        self.p1.label1 = True
        self.p2.label1 = True
        self.p3.label1 = False
        self.p1.label2 = True
        self.p2.label2 = False
        self.p3.label2 = True

        # Include both labels
        options = MockLabelFilterOptions('label1,label2', '')
        page_filter = page_filter_module.PageFilter(options)
        self.assertTrue(page_filter.IsSelected(self.p1))
        self.assertTrue(page_filter.IsSelected(self.p2))
        self.assertTrue(page_filter.IsSelected(self.p3))
        # Exclude takes priority
        options = MockLabelFilterOptions('label1', 'label2')
        page_filter = page_filter_module.PageFilter(options)
        self.assertFalse(page_filter.IsSelected(self.p1))
        self.assertTrue(page_filter.IsSelected(self.p2))
        self.assertFalse(page_filter.IsSelected(self.p3))
def _ShuffleAndFilterPageSet(page_set, options):
    if options.pageset_shuffle_order_file and not options.pageset_shuffle:
        raise Exception(
            '--pageset-shuffle-order-file requires --pageset-shuffle.')

    if options.pageset_shuffle_order_file:
        return page_set.ReorderPageSet(options.pageset_shuffle_order_file)

    page_filter = page_filter_module.PageFilter(options)
    pages = [
        page for page in page_set.pages[:]
        if not page.disabled and page_filter.IsSelected(page)
    ]

    if options.pageset_shuffle:
        random.Random().shuffle(pages)

    return pages