Пример #1
0
 def test_get_users(self, mock_model, mock_resp):
     """
     Test users retrieval.
     """
     request = mock.MagicMock()
     view = UsersView()
     response = view.get(request)
     mock_model.SERIALIZER.assert_called_once_with(mock_model.objects.return_value,
                                                   multiple=True)
     mock_resp.assert_called_once_with(mock_model.SERIALIZER.return_value.data)
     self.assertTrue(response is mock_resp.return_value)
Пример #2
0
 def test_get_users(self, mock_model, mock_resp):
     """
     Test users retrieval.
     """
     request = mock.MagicMock()
     view = UsersView()
     response = view.get(request)
     mock_model.serializer.assert_called_once_with(mock_model.objects.return_value,
                                                   multiple=True)
     mock_resp.assert_called_once_with(mock_model.serializer.return_value.data)
     self.assertTrue(response is mock_resp.return_value)
Пример #3
0
    def test_get_users(self, mock_factory, mock_resp):
        """
        Test users retrieval.
        """
        existing_users = [{'login': '******', 'name': 'test-user', 'id': '12345'}]
        mock_factory.user_query_manager.return_value.find_all.return_value = existing_users

        request = mock.MagicMock()
        view = UsersView()
        response = view.get(request)

        expected_cont = [{'_href': '/v2/users/test-user/', 'login': '******',
                          'name': 'test-user'}]
        mock_resp.assert_called_once_with(expected_cont)
        self.assertTrue(response is mock_resp.return_value)
Пример #4
0
    def test_get_users(self, mock_factory, mock_resp):
        """
        Test users retrieval.
        """
        existing_users = [{
            'login': '******',
            'name': 'test-user',
            'id': '12345'
        }]
        mock_factory.user_query_manager.return_value.find_all.return_value = existing_users

        request = mock.MagicMock()
        view = UsersView()
        response = view.get(request)

        expected_cont = [{
            '_href': '/v2/users/test-user/',
            'login': '******',
            'name': 'test-user'
        }]
        mock_resp.assert_called_once_with(expected_cont)
        self.assertTrue(response is mock_resp.return_value)