Esempio n. 1
0
    def test_get_user_roles_was_called(self, mock_get_user_roles):
        user = FakeResource(1)
        user.username = '******'

        self.mock_user_list.return_value = [user]
        mock_get_user_roles.return_value = []

        post = self.request.POST.copy()
        post.update({'project': 1})
        self.request.POST = post

        self.view(self.request)

        mock_get_user_roles.assert_called_with(user, 1)
Esempio n. 2
0
    def test_get_user_roles_was_called(self, mock_get_user_roles):
        user = FakeResource(1)
        user.username = '******'

        patch('identity.keystone.Keystone.user_list',
              Mock(return_value=[user])).start()

        mock_get_user_roles.return_value = []

        post = self.request.POST.copy()
        post.update({'project': 1})
        self.request.POST = post

        response = self.view(self.request)

        mock_get_user_roles.assert_called_with(user, 1)
Esempio n. 3
0
    def test_get_user_roles_exception(self, mock_get_user_roles):
        mock_get_user_roles.side_effect = Exception()
        mock_get_user_roles.return_value = []

        user = FakeResource(1)
        user.username = '******'

        self.mock_user_list.return_value = [user]

        post = self.request.POST.copy()
        post.update({'project': 1})
        self.request.POST = post

        response = self.view(self.request)

        self.assertEqual(response.status_code, 500)
Esempio n. 4
0
    def test_get_user_roles_was_called(self, mock_get_user_roles):
        user = FakeResource(1)
        user.username = '******'

        patch('identity.keystone.Keystone.user_list',
              Mock(return_value=[user])).start()

        mock_get_user_roles.return_value = []

        post = self.request.POST.copy()
        post.update({'project': 1})
        self.request.POST = post

        response = self.view(self.request)

        mock_get_user_roles.assert_called_with(user, 1)