Example #1
0
    def test_atCircle_string(self, mock_getIdForCircleIdentifier,
                             mock_getMentionsForCircle,
                             mock_getInstallationFromOauthId):
        mock_circleId = 1000
        mock_circleIdentier = 'sales'
        mock_command = 'Beste @Circle {}: Hoi!'.format(mock_circleIdentier)
        mock_messagedata = json.dumps(
            test_values.mock_messagedata(mock_command))

        # Error code in retrieving circleId
        mock_code = 401
        mock_message = test_values.mock_401_responsebody['message']
        mock_messageDict = messageFunctions.createMessageDict(
            strings.error_color, mock_message)

        mock_getMentionsForCircle.return_value = (
            401, test_values.mock_401_responsebody)
        mock_getIdForCircleIdentifier.return_value = (False, -999,
                                                      mock_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/atcircle',
                           follow_redirects=True,
                           data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #2
0
    def test_slash_role_roleId_string(self, mock_getIdForRoleIdentifier,
                                      mock_getRoleRoleId,
                                      mock_getInstallationFromOauthId):
        mock_roleId = 1000
        mock_roleIdentier = 'secretary'
        mock_command = '/role {}'.format(mock_roleIdentier)
        mock_messagedata = json.dumps(
            test_values.mock_messagedata(mock_command))

        # Error code in retrieving roleId
        mock_code = 401
        mock_message = test_values.mock_401_responsebody['message']
        mock_messageDict = messageFunctions.createMessageDict(
            strings.error_color, mock_message)

        mock_getRoleRoleId.return_value = (
            200, test_values.mock_role_roleId_message.format(mock_roleId))
        mock_getIdForRoleIdentifier.return_value = (False, -999, mock_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/slashrole',
                           follow_redirects=True,
                           data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #3
0
    def test_atCircle(self, mock_getMentionsForCircle,
                      mock_getInstallationFromOauthId):
        mock_circleId = 1000
        mock_command = 'Beste @Circle {}: Hoi!'.format(mock_circleId)
        mock_messagedata = json.dumps(
            test_values.mock_messagedata(mock_command))

        mock_message = test_values.mock_atcircle_message.format(
            mock_circleId, mock_circleId)
        mock_messageDict = messageFunctions.createMessageDict(
            strings.succes_color, mock_message, message_format="text")

        mock_getMentionsForCircle.return_value = (
            200, test_values.mock_atcircle_mentions.format(mock_circleId))

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/atcircle',
                           follow_redirects=True,
                           data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #4
0
    def test_slash_circle_missing_functionality(
            self, mock_getInstallationFromOauthId):
        mock_circleId = test_values.mock_circle_circleId_response['circles'][
            0]['id']
        mock_missing_functionality = 'something'
        mock_command = message = '/circle {} {}'.format(
            mock_circleId, mock_missing_functionality)
        mock_messagedata = json.dumps(
            test_values.mock_messagedata(mock_command))

        mock_color = strings.error_color
        mock_message = strings.circles_missing_functionality.format(
            mock_missing_functionality, mock_circleId)
        mock_messageDict = messageFunctions.createMessageDict(
            mock_color, mock_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/slashcircle',
                           follow_redirects=True,
                           data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #5
0
    def test_slash_role_roleId(self, mock_getRoleRoleId,
                               mock_getInstallationFromOauthId):
        mock_roleId = 1000
        mock_command = message = '/role {}'.format(mock_roleId)
        mock_messagedata = json.dumps(
            test_values.mock_messagedata(mock_command))

        mock_color = strings.succes_color
        mock_message = test_values.mock_role_roleId_message.format(mock_roleId)
        mock_messageDict = messageFunctions.createMessageDict(
            mock_color, mock_message)

        mock_getRoleRoleId.return_value = (
            200, test_values.mock_role_roleId_message.format(mock_roleId))

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/slashrole',
                           follow_redirects=True,
                           data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #6
0
    def test_hipfrog_missing_functionality(self,
                                           mock_getInstallationFromOauthId):
        mock_missing_functionality = 'something'
        mock_command = message = '/hipfrog {}'.format(
            mock_missing_functionality)
        mock_messagedata = json.dumps(
            test_values.mock_messagedata(mock_command))

        mock_color = strings.error_color
        mock_message = strings.missing_functionality.format(
            mock_missing_functionality)
        mock_messageDict = messageFunctions.createMessageDict(
            mock_color, mock_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/hipfrog',
                           follow_redirects=True,
                           data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #7
0
    def test_atCircle_string(self, mock_getIdForCircleIdentifier,
                             mock_getMentionsForCircle,
                             mock_getInstallationFromOauthId):
        mock_circleId = 1000
        mock_circleIdentier = 'sales'
        mock_command = 'Beste @Circle {}: Hoi!'.format(mock_circleIdentier)
        mock_messagedata = json.dumps(test_values.mock_messagedata(mock_command))

        # Error code in retrieving circleId
        mock_code = 401
        mock_message = test_values.mock_401_responsebody['message']
        mock_messageDict = messageFunctions.createMessageDict(
            strings.error_color, mock_message)

        mock_getMentionsForCircle.return_value = (
            401, test_values.mock_401_responsebody)
        mock_getIdForCircleIdentifier.return_value = (False, -999, mock_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/atcircle', follow_redirects=True, data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #8
0
    def test_slash_role_roleId_string(self, mock_getIdForRoleIdentifier,
                                      mock_getRoleRoleId,
                                      mock_getInstallationFromOauthId):
            mock_roleId = 1000
            mock_roleIdentier = 'secretary'
            mock_command = '/role {}'.format(mock_roleIdentier)
            mock_messagedata = json.dumps(test_values.mock_messagedata(mock_command))

            # Error code in retrieving roleId
            mock_code = 401
            mock_message = test_values.mock_401_responsebody['message']
            mock_messageDict = messageFunctions.createMessageDict(
                strings.error_color, mock_message)

            mock_getRoleRoleId.return_value = (
                200, test_values.mock_role_roleId_message.format(mock_roleId))
            mock_getIdForRoleIdentifier.return_value = (False, -999, mock_message)

            mock_headers = test_values.mock_authorization_headers()
            mock_installation = self.defaultInstallation()
            mock_getInstallationFromOauthId.return_value = mock_installation

            rv = self.app.post('/slashrole', follow_redirects=True, data=mock_messagedata,
                               headers=mock_headers)
            return_messageDict = json.loads(rv.get_data())

            assert return_messageDict == mock_messageDict
Example #9
0
    def test_hipfrog(self, mock_getInstallationFromOauthId):
        mock_messagedata = json.dumps(test_values.mock_messagedata('/hipfrog'))

        mock_color = strings.succes_color
        mock_message = strings.help_hipfrog
        mock_messageDict = messageFunctions.createMessageDict(mock_color, mock_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/hipfrog', follow_redirects=True, data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #10
0
    def test_slash_circle_roles(self, mock_getCircleRoles, mock_getInstallationFromOauthId):
        mock_messagedata = json.dumps(test_values.mock_messagedata('/circle 1000 roles'))

        mock_color = strings.succes_color
        mock_message = test_values.mock_circle_roles_message
        mock_messageDict = messageFunctions.createMessageDict(mock_color, mock_message)

        mock_getCircleRoles.return_value = (200, test_values.mock_circle_roles_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/slashcircle', follow_redirects=True, data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #11
0
    def test_hipfrog_missing_functionality(self, mock_getInstallationFromOauthId):
        mock_missing_functionality = 'something'
        mock_command = message = '/hipfrog {}'.format(mock_missing_functionality)
        mock_messagedata = json.dumps(test_values.mock_messagedata(mock_command))

        mock_color = strings.error_color
        mock_message = strings.missing_functionality.format(mock_missing_functionality)
        mock_messageDict = messageFunctions.createMessageDict(mock_color, mock_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/hipfrog', follow_redirects=True, data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #12
0
    def test_hipfrog(self, mock_getInstallationFromOauthId):
        mock_messagedata = json.dumps(test_values.mock_messagedata('/hipfrog'))

        mock_color = strings.succes_color
        mock_message = strings.help_hipfrog
        mock_messageDict = messageFunctions.createMessageDict(
            mock_color, mock_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/hipfrog',
                           follow_redirects=True,
                           data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #13
0
    def test_slash_circle_missing_functionality(self, mock_getInstallationFromOauthId):
        mock_circleId = test_values.mock_circle_circleId_response['circles'][0]['id']
        mock_missing_functionality = 'something'
        mock_command = message = '/circle {} {}'.format(mock_circleId,
                                                        mock_missing_functionality)
        mock_messagedata = json.dumps(test_values.mock_messagedata(mock_command))

        mock_color = strings.error_color
        mock_message = strings.circles_missing_functionality.format(mock_missing_functionality,
                                                                    mock_circleId)
        mock_messageDict = messageFunctions.createMessageDict(mock_color, mock_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/slashcircle', follow_redirects=True, data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #14
0
    def test_atCircle(self, mock_getMentionsForCircle, mock_getInstallationFromOauthId):
        mock_circleId = 1000
        mock_command = 'Beste @Circle {}: Hoi!'.format(mock_circleId)
        mock_messagedata = json.dumps(test_values.mock_messagedata(mock_command))

        mock_message = test_values.mock_atcircle_message.format(
            mock_circleId, mock_circleId)
        mock_messageDict = messageFunctions.createMessageDict(
            strings.succes_color, mock_message, message_format="text")

        mock_getMentionsForCircle.return_value = (
            200, test_values.mock_atcircle_mentions.format(mock_circleId))

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/atcircle', follow_redirects=True, data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #15
0
    def test_slash_role_roleId(self, mock_getRoleRoleId,
                               mock_getInstallationFromOauthId):
        mock_roleId = 1000
        mock_command = message = '/role {}'.format(mock_roleId)
        mock_messagedata = json.dumps(test_values.mock_messagedata(mock_command))

        mock_color = strings.succes_color
        mock_message = test_values.mock_role_roleId_message.format(mock_roleId)
        mock_messageDict = messageFunctions.createMessageDict(mock_color, mock_message)

        mock_getRoleRoleId.return_value = (
            200, test_values.mock_role_roleId_message.format(mock_roleId))

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/slashrole', follow_redirects=True, data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict
Example #16
0
    def test_slash_circle_roles(self, mock_getCircleRoles,
                                mock_getInstallationFromOauthId):
        mock_messagedata = json.dumps(
            test_values.mock_messagedata('/circle 1000 roles'))

        mock_color = strings.succes_color
        mock_message = test_values.mock_circle_roles_message
        mock_messageDict = messageFunctions.createMessageDict(
            mock_color, mock_message)

        mock_getCircleRoles.return_value = (
            200, test_values.mock_circle_roles_message)

        mock_headers = test_values.mock_authorization_headers()
        mock_installation = self.defaultInstallation()
        mock_getInstallationFromOauthId.return_value = mock_installation

        rv = self.app.post('/slashcircle',
                           follow_redirects=True,
                           data=mock_messagedata,
                           headers=mock_headers)
        return_messageDict = json.loads(rv.get_data())

        assert return_messageDict == mock_messageDict