

def test_status_action_methods_manager(self):
    '\n        Test if action methods return appropriate status\n        '

    class MockManager(SessionMixin, AlchemyModelManager):
        model_class = mock.Mock()
        action_methods = {
            'action_method': ['POST', 'DELETE'],
            'accept_method': ['POST'],
            'update_method': ['POST'],
        }

        def action_method(self, data, *args, **kwargs):
            "\n                Return back status as 'created' and data in 'result' key\n                "
            return {
                'status': 'created',
                'result': 'some_data',
            }

        def accept_method(self, data, pk=None, **kwargs):
            '\n                assert if self.session is available\n                '
            assert (self.session is not None)
            return {
                'status': 'accepted',
            }

        def update_method(self, data, pk=None, **kwargs):
            return {
                'status': 'updated',
            }

    class MockViewSet(AlchemyModelViewSet, ManagerMixin):
        manager_class = MockManager
    mock_request = mock.Mock()
    mock_request.data = {
        
    }
    viewset = MockViewSet()
    r = viewset.action_method(mock_request)
    self.assertEqual(r.status_code, status.HTTP_201_CREATED)
    r = viewset.accept_method(mock_request)
    self.assertEqual(r.status_code, status.HTTP_202_ACCEPTED)
    r = viewset.update_method(mock_request)
    self.assertEqual(r.status_code, status.HTTP_200_OK)

dataset/ETHPy150Open dealertrack/djangorest-alchemy/djangorest_alchemy/tests/test_viewsets.py TestAlchemyViewSetUnit.test_status_action_methods_manager/original