Esempio n. 1
0
    def test_add_invalid_user_to_role(self):
        """
        Test add invalid user to a role.
        """
        request = mock.MagicMock()
        request.body = json.dumps({'login': None})
        role_users = RoleUsersView()

        try:
            response = role_users.post(request, 'test-role')
        except InvalidValue, response:
            pass
Esempio n. 2
0
    def test_add_invalid_user_to_role(self):
        """
        Test add invalid user to a role.
        """
        request = mock.MagicMock()
        request.body = json.dumps({'login': None})
        role_users = RoleUsersView()

        try:
            response = role_users.post(request, 'test-role')
        except InvalidValue, response:
            pass
Esempio n. 3
0
    def test_add_user_to_role(self, mock_factory, mock_resp):
        """
        Test add user to a role.
        """
        mock_factory.role_manager.return_value.add_user_to_role.return_value = None

        request = mock.MagicMock()
        request.body = json.dumps({'login': '******'})
        role_users = RoleUsersView()
        response = role_users.post(request, 'test-role')

        mock_resp.assert_called_once_with(None)
        self.assertTrue(response is mock_resp.return_value)
Esempio n. 4
0
    def test_add_user_to_role(self, mock_factory, mock_resp):
        """
        Test add user to a role.
        """
        mock_factory.role_manager.return_value.add_user_to_role.return_value = None

        request = mock.MagicMock()
        request.body = json.dumps({'login': '******'})
        role_users = RoleUsersView()
        response = role_users.post(request, 'test-role')

        mock_resp.assert_called_once_with(None)
        self.assertTrue(response is mock_resp.return_value)