def test_create_without_data(mommy, serializer):
    mommy.make.return_value = Mock(pk=1)
    view = TestDataModelRestView()
    view.data = None
    view.model = Mock()
    view.post(None)
    mommy.make.assert_called_once_with(view.model)
    view.model.objects.get.assert_called_once_with(pk=1)
    serializer.serialize.assert_called_once_with([view.model.objects.get()])
def test_create(mommy, get_data, serializer):
    get_data.side_effect = lambda data: data
    mommy.make.return_value = Mock(pk=1)
    view = TestDataModelRestView()
    view.data = {'test_data': 'test'}
    view.model = Mock()
    view.post(None)
    mommy.make.assert_called_once_with(view.model, test_data='test')
    view.model.objects.get.assert_called_once_with(pk=1)
    serializer.serialize.assert_called_once_with([view.model.objects.get()])