def make_mocks(cls, patcherize):
        cls.mocks = patcherize(
            (('ConfigParser', 'highfive.newpr.ConfigParser'), ))

        config_mock = mock.Mock()
        config_mock.get.side_effect = ('integration-user', 'integration-token')
        cls.mocks['ConfigParser'].RawConfigParser.return_value = config_mock
Example #2
0
 def make_mocks(cls, patcherize):
     cls.mocks = patcherize((
         ('is_collaborator',
          'highfive.newpr.HighfiveHandler.is_collaborator'),
         ('find_reviewer', 'highfive.newpr.HighfiveHandler.find_reviewer'),
         ('set_assignee', 'highfive.newpr.HighfiveHandler.set_assignee'),
     ))
Example #3
0
    def make_defaults(cls, patcherize):
        cls.mocks = patcherize(
            (('api_req', 'highfive.newpr.HighfiveHandler.api_req'), ))
        cls.payload = Payload({'repository': {'fork': False}})

        cls.username = '******'
        cls.owner = 'repo-owner'
        cls.repo = 'repo-name'
        cls.token = 'integrationToken'
Example #4
0
    def make_mocks(cls, patcherize):
        cls.mocks = patcherize((
            ('ConfigParser', 'highfive.newpr.ConfigParser'),
            ('load_json_file', 'highfive.newpr.HighfiveHandler._load_json_file'),
        ))

        cls.mocks['load_json_file'].side_effect = (
            fakes.get_repo_configs()['individuals_no_dirs'],
            fakes.get_global_configs()['base'],
        )
Example #5
0
    def make_mocks(cls, patcherize):
        cls.mocks = patcherize((
            ('get_irc_nick', 'highfive.newpr.HighfiveHandler.get_irc_nick'),
            ('ConfigParser', 'highfive.newpr.ConfigParser'),
        ))

        cls.mocks['get_irc_nick'].return_value = None

        config_mock = mock.Mock()
        config_mock.get.side_effect = ('integration-user', 'integration-token')
        cls.mocks['ConfigParser'].RawConfigParser.return_value = config_mock
Example #6
0
    def make_mocks(cls, patcherize):
        cls.mocks = patcherize((
            ('get_irc_nick', 'highfive.newpr.HighfiveHandler.get_irc_nick'),
            ('ConfigParser', 'highfive.newpr.ConfigParser'),
            ('load_json_file', 'highfive.newpr.HighfiveHandler._load_json_file'),
        ))

        cls.mocks['get_irc_nick'].return_value = None

        cls.mocks['load_json_file'].side_effect = (
            fakes.get_repo_configs()['individuals_no_dirs'],
            fakes.get_global_configs()['base'],
        )
Example #7
0
    def make_defaults(cls, patcherize):
        cls.mocks = patcherize((
            ('api_req', 'highfive.newpr.HighfiveHandler.api_req'),
            ('post_comment', 'highfive.newpr.HighfiveHandler.post_comment'),
        ))

        cls.handler = HighfiveHandlerMock(Payload({})).handler
        cls.assignee = 'assigneeUser'
        cls.author = 'authorUser'
        cls.owner = 'repo-owner'
        cls.repo = 'repo-name'
        cls.issue = 7
        cls.user = '******'
        cls.token = 'integrationToken'
Example #8
0
    def tpw_defaults(cls, patcherize):
        cls.mocks = patcherize((
            ('unexpected_branch', 'highfive.newpr.HighfiveHandler.unexpected_branch'),
            ('modifies_submodule', 'highfive.newpr.HighfiveHandler.modifies_submodule'),
            ('post_comment', 'highfive.newpr.HighfiveHandler.post_comment'),
        ))

        cls.payload = Payload({'the': 'payload'})
        cls.config = {'the': 'config'}
        cls.diff = 'the diff'
        cls.owner = 'repo-owner'
        cls.repo = 'repo-name'
        cls.issue = 7
        cls.token = 'integrationToken'

        cls.handler = HighfiveHandlerMock(
            cls.payload, repo_config=cls.config
        ).handler
    def make_mocks(cls, patcherize):
        cls.mocks = patcherize((
            ('get_irc_nick', 'highfive.newpr.HighfiveHandler.get_irc_nick'),
            ('ConfigParser', 'highfive.newpr.ConfigParser'),
            ('load_json_file',
             'highfive.newpr.HighfiveHandler._load_json_file'),
        ))

        cls.mocks['get_irc_nick'].return_value = None

        config_mock = mock.Mock()
        config_mock.get.side_effect = ('integration-user', 'integration-token')
        cls.mocks['ConfigParser'].RawConfigParser.return_value = config_mock

        cls.mocks['load_json_file'].side_effect = (
            fakes.get_repo_configs()['individuals_no_dirs'],
            fakes.get_global_configs()['base'],
        )
Example #10
0
    def make_defaults(cls, patcherize):
        cls.mocks = patcherize((
            ('api_req', 'highfive.newpr.HighfiveHandler.api_req'),
            ('find_reviewer', 'highfive.newpr.HighfiveHandler.find_reviewer'),
            ('choose_reviewer', 'highfive.newpr.HighfiveHandler.choose_reviewer'),
            ('set_assignee', 'highfive.newpr.HighfiveHandler.set_assignee'),
            ('is_new_contributor', 'highfive.newpr.HighfiveHandler.is_new_contributor'),
            ('post_comment', 'highfive.newpr.HighfiveHandler.post_comment'),
            ('welcome_msg', 'highfive.newpr.HighfiveHandler.welcome_msg'),
            ('review_msg', 'highfive.newpr.HighfiveHandler.review_msg'),
            ('post_warnings', 'highfive.newpr.HighfiveHandler.post_warnings'),
            ('add_labels', 'highfive.newpr.HighfiveHandler.add_labels'),
        ))

        cls.mocks['api_req'].return_value = {'body': 'diff'}

        cls.payload = fakes.Payload.new_pr()
        cls.config = {'the': 'config', 'new_pr_labels': ['foo-label']}
        cls.user = '******'
        cls.token = 'integrationToken'
Example #11
0
    def make_defaults(cls, patcherize):
        cls.mocks = patcherize((
            ('urlopen', 'urllib.request.urlopen'),
            ('Request', 'urllib.request.Request'),
            ('StringIO', 'highfive.newpr.StringIO'),
            ('GzipFile', 'gzip.GzipFile'),
        ))

        cls.req = cls.mocks['Request'].return_value

        cls.res = cls.mocks['urlopen'].return_value
        cls.res.info.return_value = {'Content-Encoding': 'gzip'}

        cls.body = cls.res.read.return_value = b'body1'

        cls.gzipped_body = cls.mocks['GzipFile'].return_value.read
        cls.gzipped_body.return_value = b'body2'

        cls.handler = HighfiveHandlerMock(Payload({})).handler

        cls.method = 'METHOD'
        cls.url = 'https://foo.bar'
Example #12
0
 def make_mocks(cls, patcherize):
     cls.mocks = patcherize((
         ('new_pr', 'highfive.newpr.HighfiveHandler.new_pr'),
         ('new_comment', 'highfive.newpr.HighfiveHandler.new_comment'),
     ))