class TestDistributionOrProductVocabulary(TestCaseWithFactory, VocabFilterMixin): """Test that the ProductVocabulary behaves as expected.""" layer = DatabaseFunctionalLayer def setUp(self): super(TestDistributionOrProductVocabulary, self).setUp() self.vocabulary = DistributionOrProductVocabulary() self.product = self.factory.makeProduct(name="orchid-snark") self.distribution = self.factory.makeDistribution(name="zebra-snark") def test_supported_filters(self): # The vocab supports the correct filters. self.assertEqual( [ DistributionOrProductVocabulary.ALL_FILTER, DistributionOrProductVocabulary.PROJECT_FILTER, DistributionOrProductVocabulary.DISTRO_FILTER, ], self.vocabulary.supportedFilters(), ) def test_project_filter(self): self._test_project_filter() def test_distribution_filter(self): self._test_distribution_filter() def test_inactive_products_are_excluded(self): # Inactive product are not in the vocabulary. with celebrity_logged_in("registry_experts"): self.product.active = False terms = self.vocabulary.searchForTerms("snark") result = [term.value for term in terms] self.assertEqual([self.distribution], result) self.assertFalse(self.product in self.vocabulary) def test_project_groups_are_excluded(self): # Project groups are not in the vocabulary. project_group = self.factory.makeProject(name="apple-snark") terms = self.vocabulary.searchForTerms("snark") result = [term.value for term in terms] self.assertEqual([self.product, self.distribution], result) self.assertFalse(project_group in self.vocabulary)
class TestDistributionOrProductVocabulary(TestCaseWithFactory, VocabFilterMixin): """Test that the ProductVocabulary behaves as expected.""" layer = DatabaseFunctionalLayer def setUp(self): super(TestDistributionOrProductVocabulary, self).setUp() self.vocabulary = DistributionOrProductVocabulary() self.product = self.factory.makeProduct(name='orchid-snark') self.distribution = self.factory.makeDistribution(name='zebra-snark') def test_supported_filters(self): # The vocab supports the correct filters. self.assertEqual([ DistributionOrProductVocabulary.ALL_FILTER, DistributionOrProductVocabulary.PROJECT_FILTER, DistributionOrProductVocabulary.DISTRO_FILTER, ], self.vocabulary.supportedFilters() ) def test_project_filter(self): self._test_project_filter() def test_distribution_filter(self): self._test_distribution_filter() def test_inactive_products_are_excluded(self): # Inactive product are not in the vocabulary. with celebrity_logged_in('registry_experts'): self.product.active = False terms = self.vocabulary.searchForTerms('snark') result = [term.value for term in terms] self.assertEqual([self.distribution], result) self.assertFalse(self.product in self.vocabulary) def test_project_groups_are_excluded(self): # Project groups are not in the vocabulary. project_group = self.factory.makeProject(name='apple-snark') terms = self.vocabulary.searchForTerms('snark') result = [term.value for term in terms] self.assertEqual([self.product, self.distribution], result) self.assertFalse(project_group in self.vocabulary)
def setUp(self): super(TestDistributionOrProductVocabulary, self).setUp() self.vocabulary = DistributionOrProductVocabulary() self.product = self.factory.makeProduct(name="orchid-snark") self.distribution = self.factory.makeDistribution(name="zebra-snark")
def setUp(self): super(TestDistributionOrProductVocabulary, self).setUp() self.vocabulary = DistributionOrProductVocabulary() self.product = self.factory.makeProduct(name='orchid-snark') self.distribution = self.factory.makeDistribution(name='zebra-snark')