Example #1
0
File: test.py Project: martenson/p4
    def test_find_in_comments(self):
        comments_container = [
            [AttrDict({'body': '+1', 'expect': True})],
            [AttrDict({'body': ':+1:', 'expect': True})],
            [AttrDict({'body': 'asdf +1 asdf', 'expect': False})],
            [AttrDict({'body': 'asdf :+1: asdf', 'expect': True})],
            [AttrDict({'body': 'asdf\n+1\nasdf', 'expect': True})],
            [AttrDict({'body': 'asdf\n:+1:\nasdf', 'expect': True})],
            [AttrDict({'body': """Yeah, dunno about travis either, but I'm a bit nervous to break the build for everyone else.
You have my :+1:, but I'd like a second pair of eyes merging this.""", 'expect': True})],
        ]
        for x in comments_container:
            # Get comments needs to return a callable, so we shoehorn in a
            # closure to return 'x'
            prf = PullRequestFilter("test_filter", [], [])

            def q():
                return x

            # Then set up as function on fpr. There's probably an easier way to
            # do this but whatever.
            prf.issue = AttrDict({
                'get_comments': q
            })
            fpr = AttrDict({
            })
            result = len(list(prf._find_in_comments(fpr, UPVOTE_REGEX))) > 0,
            self.assertEquals(
                result[0],
                x[0]['expect'],
                msg="body: '%s' did not produce the expected result." % x[0]['body']
            )
Example #2
0
    def test_find_in_comments(self):
        comments_container = [
            [AttrDict({
                'body': '+1',
                'expect': True
            })],
            [AttrDict({
                'body': ':+1:',
                'expect': True
            })],
            [AttrDict({
                'body': 'asdf +1 asdf',
                'expect': False
            })],
            [AttrDict({
                'body': 'asdf :+1: asdf',
                'expect': True
            })],
            [AttrDict({
                'body': 'asdf\n+1\nasdf',
                'expect': True
            })],
            [AttrDict({
                'body': 'asdf\n:+1:\nasdf',
                'expect': True
            })],
            [
                AttrDict({
                    'body':
                    """Yeah, dunno about travis either, but I'm a bit nervous to break the build for everyone else.
You have my :+1:, but I'd like a second pair of eyes merging this.""",
                    'expect': True
                })
            ],
        ]
        for x in comments_container:
            # Get comments needs to return a callable, so we shoehorn in a
            # closure to return 'x'
            prf = PullRequestFilter("test_filter", [], [])

            def q():
                return x

            # Then set up as function on fpr. There's probably an easier way to
            # do this but whatever.
            prf.issue = AttrDict({'get_comments': q})
            fpr = AttrDict({})
            result = len(list(prf._find_in_comments(fpr, UPVOTE_REGEX))) > 0,
            self.assertEquals(
                result[0],
                x[0]['expect'],
                msg="body: '%s' did not produce the expected result." %
                x[0]['body'])
Example #3
0
File: test.py Project: jmchilton/p4
 def test_find_in_comments(self):
     prf = PullRequestFilter("test_filter", [], [])
     comments_container = [
         [[AttrDict({"body": "+1", "expect": True})]],
         [[AttrDict({"body": ":+1:", "expect": True})]],
         [[AttrDict({"body": "asdf +1 asdf", "expect": False})]],
         [[AttrDict({"body": "asdf :+1: asdf", "expect": True})]],
         [[AttrDict({"body": "asdf\n+1\nasdf", "expect": True})]],
         [[AttrDict({"body": "asdf\n:+1:\nasdf", "expect": True})]],
     ]
     for x in comments_container:
         result = (len(list(prf._find_in_comments(x, "(:\+1:|^\s*\+1\s*$)"))) > 0,)
         self.assertEquals(
             result[0], x[0][0]["expect"], msg="body: '%s' did not produce the expected result." % x[0][0]["body"]
         )
Example #4
0
File: test.py Project: jmchilton/p4
 def test_find_in_comments(self):
     prf = PullRequestFilter("test_filter", [], [])
     comments_container = [
         [[AttrDict({
             'body': '+1',
             'expect': True
         })]],
         [[AttrDict({
             'body': ':+1:',
             'expect': True
         })]],
         [[AttrDict({
             'body': 'asdf +1 asdf',
             'expect': False
         })]],
         [[AttrDict({
             'body': 'asdf :+1: asdf',
             'expect': True
         })]],
         [[AttrDict({
             'body': 'asdf\n+1\nasdf',
             'expect': True
         })]],
         [[AttrDict({
             'body': 'asdf\n:+1:\nasdf',
             'expect': True
         })]],
     ]
     for x in comments_container:
         result = len(list(prf._find_in_comments(
             x, '(:\+1:|^\s*\+1\s*$)'))) > 0,
         self.assertEquals(
             result[0],
             x[0][0]['expect'],
             msg="body: '%s' did not produce the expected result." %
             x[0][0]['body'])