def test_match_conditions(self): """Testing IntegrationConfig.match_conditions""" config = IntegrationConfig() config.settings['my_conditions'] = { 'mode': 'all', 'conditions': [ { 'choice': 'branch', 'op': 'is', 'value': 'master', }, { 'choice': 'summary', 'op': 'contains', 'value': '[WIP]', }, ], } review_request = self.create_review_request( branch='master', summary='[WIP] This is a test.') self.assertTrue( config.match_conditions(MyConfigForm, conditions_key='my_conditions', review_request=review_request)) review_request = self.create_review_request(branch='master', summary='This is a test.') self.assertFalse( config.match_conditions(MyConfigForm, conditions_key='my_conditions', review_request=review_request))
def test_match_conditions_sandbox(self): """Testing IntegrationConfig.match_conditions with exceptions sandboxed """ config = IntegrationConfig() config.settings['my_conditions'] = { 'mode': 'all', 'conditions': [ { 'choice': 'branch', 'op': 'is', 'value': 'master', }, { 'choice': 'summary', 'op': 'contains', 'value': '[WIP]', }, ], } self.create_review_request(branch='master', summary='[WIP] This is a test.') self.spy_on(logging.exception) self.assertFalse( config.match_conditions(MyConfigForm, conditions_key='my_conditions', review_request='test')) self.assertTrue(logging.exception.spy.called)
def test_match_conditions_sandbox(self): """Testing IntegrationConfig.match_conditions with exceptions sandboxed """ config = IntegrationConfig() config.settings['my_conditions'] = { 'mode': 'all', 'conditions': [ { 'choice': 'branch', 'op': 'is', 'value': 'master', }, { 'choice': 'summary', 'op': 'contains', 'value': '[WIP]', }, ], } self.create_review_request( branch='master', summary='[WIP] This is a test.') self.spy_on(logging.exception) self.assertFalse(config.match_conditions( MyConfigForm, conditions_key='my_conditions', review_request='test')) self.assertTrue(logging.exception.spy.called)
def test_match_conditions(self): """Testing IntegrationConfig.match_conditions""" config = IntegrationConfig() config.settings['my_conditions'] = { 'mode': 'all', 'conditions': [ { 'choice': 'branch', 'op': 'is', 'value': 'master', }, { 'choice': 'summary', 'op': 'contains', 'value': '[WIP]', }, ], } review_request = self.create_review_request( branch='master', summary='[WIP] This is a test.') self.assertTrue(config.match_conditions( MyConfigForm, conditions_key='my_conditions', review_request=review_request)) review_request = self.create_review_request( branch='master', summary='This is a test.') self.assertFalse(config.match_conditions( MyConfigForm, conditions_key='my_conditions', review_request=review_request))