def test_build_invalidfilter(): notification_data = AttrDict({ "event_config_dict": { "ref-regex": "][" }, }) # No build data at all. assert not BuildSuccessEvent().should_perform({}, notification_data) # With trigger metadata but no ref. assert not BuildSuccessEvent().should_perform( { "trigger_metadata": {}, }, notification_data, ) # With trigger metadata and a ref. assert not BuildSuccessEvent().should_perform( { "trigger_metadata": { "ref": "refs/heads/somebranch", }, }, notification_data, )
def test_build_withfilter(): notification_data = AttrDict({ 'event_config_dict': { "ref-regex": "refs/heads/master" }, }) # No build data at all. assert not BuildSuccessEvent().should_perform({}, notification_data) # With trigger metadata but no ref. assert not BuildSuccessEvent().should_perform({ 'trigger_metadata': {}, }, notification_data) # With trigger metadata and a not-matching ref. assert not BuildSuccessEvent().should_perform( { 'trigger_metadata': { 'ref': 'refs/heads/somebranch', }, }, notification_data) # With trigger metadata and a matching ref. assert BuildSuccessEvent().should_perform( { 'trigger_metadata': { 'ref': 'refs/heads/master', }, }, notification_data)
def test_build_emptyjson(): notification_data = AttrDict({ "event_config_dict": None, }) # No build data at all. assert BuildSuccessEvent().should_perform({}, notification_data)
def test_build_withwildcardfilter(): notification_data = AttrDict({ "event_config_dict": { "ref-regex": "refs/heads/.+" }, }) # No build data at all. assert not BuildSuccessEvent().should_perform({}, notification_data) # With trigger metadata but no ref. assert not BuildSuccessEvent().should_perform( { "trigger_metadata": {}, }, notification_data, ) # With trigger metadata and a not-matching ref. assert not BuildSuccessEvent().should_perform( { "trigger_metadata": { "ref": "refs/tags/sometag", }, }, notification_data, ) # With trigger metadata and a matching ref. assert BuildSuccessEvent().should_perform( { "trigger_metadata": { "ref": "refs/heads/master", }, }, notification_data, ) # With trigger metadata and another matching ref. assert BuildSuccessEvent().should_perform( { "trigger_metadata": { "ref": "refs/heads/somebranch", }, }, notification_data, )
def test_build_nofilter(): notification_data = AttrDict({ 'event_config_dict': {}, }) # No build data at all. assert BuildSuccessEvent().should_perform({}, notification_data) # With trigger metadata but no ref. assert BuildSuccessEvent().should_perform({ 'trigger_metadata': {}, }, notification_data) # With trigger metadata and a ref. assert BuildSuccessEvent().should_perform( { 'trigger_metadata': { 'ref': 'refs/heads/somebranch', }, }, notification_data)