コード例 #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
コード例 #2
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)
コード例 #3
0
    def test_list_users_beloging_to_role(self, mock_fact, mock_resp):
        """
        Test list Users belonging to a role.
        """
        resp = {'login': '******', 'name': 'bar'}
        expected_cont = {'login': '******', 'name': 'bar'}

        mock_fact.user_query_manager.return_value.find_users_belonging_to_role.return_value = resp
        request = mock.MagicMock()
        role_users = RoleUsersView()
        response = role_users.get(request, 'test-role')

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