- Move each trigger handler into its own file - Add dictionary helper classes for easier reading and writing of dict-based data - Extract the web hook payload -> internal representation building for each trigger system - Add tests for this transformation - Remove support for Github archived-based building
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
import unittest
|
|
import re
|
|
|
|
from buildtrigger.triggerutil import matches_ref
|
|
|
|
class TestRegex(unittest.TestCase):
|
|
def assertDoesNotMatch(self, ref, filt):
|
|
self.assertFalse(matches_ref(ref, re.compile(filt)))
|
|
|
|
def assertMatches(self, ref, filt):
|
|
self.assertTrue(matches_ref(ref, re.compile(filt)))
|
|
|
|
def test_matches_ref(self):
|
|
self.assertMatches('ref/heads/master', '.+')
|
|
self.assertMatches('ref/heads/master', 'heads/.+')
|
|
self.assertMatches('ref/heads/master', 'heads/master')
|
|
|
|
self.assertDoesNotMatch('ref/heads/foobar', 'heads/master')
|
|
self.assertDoesNotMatch('ref/heads/master', 'tags/master')
|
|
|
|
self.assertMatches('ref/heads/master', '(((heads/alpha)|(heads/beta))|(heads/gamma))|(heads/master)')
|
|
self.assertMatches('ref/heads/alpha', '(((heads/alpha)|(heads/beta))|(heads/gamma))|(heads/master)')
|
|
self.assertMatches('ref/heads/beta', '(((heads/alpha)|(heads/beta))|(heads/gamma))|(heads/master)')
|
|
self.assertMatches('ref/heads/gamma', '(((heads/alpha)|(heads/beta))|(heads/gamma))|(heads/master)')
|
|
|
|
self.assertDoesNotMatch('ref/heads/delta', '(((heads/alpha)|(heads/beta))|(heads/gamma))|(heads/master)')
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|