class ReviewRequestRepositoryTypeChoiceTests(TestCase): """Unit tests for ReviewRequestRepositoryTypeChoice.""" fixtures = ['test_scmtools', 'test_users'] def setUp(self): super(ReviewRequestRepositoryTypeChoiceTests, self).setUp() self.choice = ReviewRequestRepositoryTypeChoice() def test_matches_with_one_of_op(self): """Testing ReviewRequestRepositoryTypeChoice.matches with "one-of" operator """ repository1 = self.create_repository(name='repo1', tool_name='Git') repository2 = self.create_repository(name='repo2', tool_name='Subversion') repository3 = self.create_repository(name='repo3', tool_name='CVS') condition_set = ConditionSet(ConditionSet.MODE_ALL, [ Condition(self.choice, self.choice.get_operator('one-of'), [repository1.tool, repository2.tool]) ]) self.assertTrue( condition_set.matches(review_request=self.create_review_request( repository=repository1))) self.assertTrue( condition_set.matches(review_request=self.create_review_request( repository=repository2))) self.assertFalse( condition_set.matches(review_request=self.create_review_request( repository=repository3))) def test_matches_with_not_one_of_op(self): """Testing ReviewRequestRepositoryTypeChoice.matches with "not-one-of" operator """ repository1 = self.create_repository(name='repo1', tool_name='Git') repository2 = self.create_repository(name='repo2', tool_name='Subversion') repository3 = self.create_repository(name='repo3', tool_name='CVS') condition_set = ConditionSet(ConditionSet.MODE_ALL, [ Condition(self.choice, self.choice.get_operator('not-one-of'), [repository1.tool, repository2.tool]) ]) self.assertFalse( condition_set.matches(review_request=self.create_review_request( repository=repository1))) self.assertFalse( condition_set.matches(review_request=self.create_review_request( repository=repository2))) self.assertTrue( condition_set.matches(review_request=self.create_review_request( repository=repository3)))
class ReviewRequestRepositoryTypeChoiceTests(TestCase): """Unit tests for ReviewRequestRepositoryTypeChoice.""" fixtures = ['test_scmtools', 'test_users'] def setUp(self): super(ReviewRequestRepositoryTypeChoiceTests, self).setUp() self.choice = ReviewRequestRepositoryTypeChoice() def test_matches_with_one_of_op(self): """Testing ReviewRequestRepositoryTypeChoice.matches with "one-of" operator """ repository1 = self.create_repository(name='repo1', tool_name='Git') repository2 = self.create_repository(name='repo2', tool_name='Subversion') repository3 = self.create_repository(name='repo3', tool_name='CVS') condition_set = ConditionSet(ConditionSet.MODE_ALL, [ Condition(self.choice, self.choice.get_operator('one-of'), [repository1.tool, repository2.tool]) ]) self.assertTrue(condition_set.matches( review_request=self.create_review_request(repository=repository1))) self.assertTrue(condition_set.matches( review_request=self.create_review_request(repository=repository2))) self.assertFalse(condition_set.matches( review_request=self.create_review_request(repository=repository3))) def test_matches_with_not_one_of_op(self): """Testing ReviewRequestRepositoryTypeChoice.matches with "not-one-of" operator """ repository1 = self.create_repository(name='repo1', tool_name='Git') repository2 = self.create_repository(name='repo2', tool_name='Subversion') repository3 = self.create_repository(name='repo3', tool_name='CVS') condition_set = ConditionSet(ConditionSet.MODE_ALL, [ Condition(self.choice, self.choice.get_operator('not-one-of'), [repository1.tool, repository2.tool]) ]) self.assertFalse(condition_set.matches( review_request=self.create_review_request(repository=repository1))) self.assertFalse(condition_set.matches( review_request=self.create_review_request(repository=repository2))) self.assertTrue(condition_set.matches( review_request=self.create_review_request(repository=repository3)))
def setUp(self): super(ReviewRequestRepositoryTypeChoiceTests, self).setUp() self.choice = ReviewRequestRepositoryTypeChoice()