# Path: rest_framework_extensions/settings.py
# USER_SETTINGS = getattr(settings, 'REST_FRAMEWORK_EXTENSIONS', None)
# DEFAULTS = {
#     # caching
#     'DEFAULT_USE_CACHE': 'default',
#     'DEFAULT_CACHE_RESPONSE_TIMEOUT': None,
#     'DEFAULT_CACHE_ERRORS': True,
#     'DEFAULT_CACHE_KEY_FUNC': 'rest_framework_extensions.utils.default_cache_key_func',
#     'DEFAULT_OBJECT_CACHE_KEY_FUNC': 'rest_framework_extensions.utils.default_object_cache_key_func',
#     'DEFAULT_LIST_CACHE_KEY_FUNC': 'rest_framework_extensions.utils.default_list_cache_key_func',
# 
#     # ETAG
#     'DEFAULT_ETAG_FUNC': 'rest_framework_extensions.utils.default_etag_func',
#     'DEFAULT_OBJECT_ETAG_FUNC': 'rest_framework_extensions.utils.default_object_etag_func',
#     'DEFAULT_LIST_ETAG_FUNC': 'rest_framework_extensions.utils.default_list_etag_func',
# 
#     # API - ETAG
#     'DEFAULT_API_OBJECT_ETAG_FUNC': 'rest_framework_extensions.utils.default_api_object_etag_func',
#     'DEFAULT_API_LIST_ETAG_FUNC': 'rest_framework_extensions.utils.default_api_list_etag_func',
# 
#     # other
#     'DEFAULT_KEY_CONSTRUCTOR_MEMOIZE_FOR_REQUEST': False,
#     'DEFAULT_BULK_OPERATION_HEADER_NAME': 'X-BULK-OPERATION',
#     'DEFAULT_PARENT_LOOKUP_KWARG_NAME_PREFIX': 'parent_lookup_'
# }
# IMPORT_STRINGS = [
#     'DEFAULT_CACHE_KEY_FUNC',
#     'DEFAULT_OBJECT_CACHE_KEY_FUNC',
#     'DEFAULT_LIST_CACHE_KEY_FUNC',
#     'DEFAULT_ETAG_FUNC',
#     'DEFAULT_OBJECT_ETAG_FUNC',
#     'DEFAULT_LIST_ETAG_FUNC',
#     # API - ETAG
#     'DEFAULT_API_OBJECT_ETAG_FUNC',
#     'DEFAULT_API_LIST_ETAG_FUNC',
# ]
# 
# Path: rest_framework_extensions/utils.py
# def get_rest_framework_version():
# def flatten(list_of_lists):
# def prepare_header_name(name):
# def get_unique_method_id(view_instance, view_method):
# def get_model_opts_concrete_fields(opts):
# def compose_parent_pk_kwarg_name(value):
# 
# Path: tests_app/tests/functional/mixins/list_update_model_mixin/models.py
# class CommentForListUpdateModelMixin(models.Model):
#     email = models.EmailField()
# 
# class UserForListUpdateModelMixin(models.Model):
#     email = models.EmailField()
#     name = models.CharField(max_length=10)
#     age = models.IntegerField()
#     last_name = models.CharField(max_length=10)
#     password = models.CharField(max_length=100)
# 
# Path: tests_app/testutils.py
# def override_extensions_api_settings(**kwargs):
#     return patch.multiple(
#         'rest_framework_extensions.settings.extensions_api_settings',
#         **kwargs
#     )


import json
import unittest
import django
from django.test import override_settings
from rest_framework.test import APITestCase
from rest_framework_extensions.settings import extensions_api_settings
from rest_framework_extensions import utils
from .models import (
    CommentForListUpdateModelMixin as Comment,
    UserForListUpdateModelMixin as User
)
from tests_app.testutils import override_extensions_api_settings
        self.assertEqual(resp.status_code, 204)
        for comment in Comment.objects.all():
            self.assertEqual(comment.email, self.patch_data['email'])

    def test_bulk_partial_update__should_update_filtered_queryset(self):
        resp = self.client.patch('/comments/?id=1', data=json.dumps(self.patch_data), content_type='application/json', **self.protection_headers)
        self.assertEqual(resp.status_code, 204)
        self.assertEqual(Comment.objects.get(pk=1).email, self.patch_data['email'])
        self.assertEqual(Comment.objects.get(pk=2).email, self.comments[1].email)

    def test_bulk_partial_update__should_not_update_if_client_has_no_permissions(self):
        resp = self.client.patch('/comments-with-permission/', data=json.dumps(self.patch_data), content_type='application/json', **self.protection_headers)
        self.assertEqual(resp.status_code, 404)
        for i, comment in enumerate(Comment.objects.all()):
            self.assertEqual(comment.email, self.comments[i].email)


@override_settings(ROOT_URLCONF='tests_app.tests.functional.mixins.list_update_model_mixin.urls')
class ListUpdateModelMixinTestBehaviour__serializer_fields(APITestCase):

    def setUp(self):
        self.user = User.objects.create(
            id=1,
            name='Gennady',
            age=24,
            last_name='Chibisov',
            email='example@ya.ru',
            password='somepassword'
        )
        self.headers = {

# Path: rest_framework_extensions/settings.py
# USER_SETTINGS = getattr(settings, 'REST_FRAMEWORK_EXTENSIONS', None)
# DEFAULTS = {
#     # caching
#     'DEFAULT_USE_CACHE': 'default',
#     'DEFAULT_CACHE_RESPONSE_TIMEOUT': None,
#     'DEFAULT_CACHE_ERRORS': True,
#     'DEFAULT_CACHE_KEY_FUNC': 'rest_framework_extensions.utils.default_cache_key_func',
#     'DEFAULT_OBJECT_CACHE_KEY_FUNC': 'rest_framework_extensions.utils.default_object_cache_key_func',
#     'DEFAULT_LIST_CACHE_KEY_FUNC': 'rest_framework_extensions.utils.default_list_cache_key_func',
# 
#     # ETAG
#     'DEFAULT_ETAG_FUNC': 'rest_framework_extensions.utils.default_etag_func',
#     'DEFAULT_OBJECT_ETAG_FUNC': 'rest_framework_extensions.utils.default_object_etag_func',
#     'DEFAULT_LIST_ETAG_FUNC': 'rest_framework_extensions.utils.default_list_etag_func',
# 
#     # API - ETAG
#     'DEFAULT_API_OBJECT_ETAG_FUNC': 'rest_framework_extensions.utils.default_api_object_etag_func',
#     'DEFAULT_API_LIST_ETAG_FUNC': 'rest_framework_extensions.utils.default_api_list_etag_func',
# 
#     # other
#     'DEFAULT_KEY_CONSTRUCTOR_MEMOIZE_FOR_REQUEST': False,
#     'DEFAULT_BULK_OPERATION_HEADER_NAME': 'X-BULK-OPERATION',
#     'DEFAULT_PARENT_LOOKUP_KWARG_NAME_PREFIX': 'parent_lookup_'
# }
# IMPORT_STRINGS = [
#     'DEFAULT_CACHE_KEY_FUNC',
#     'DEFAULT_OBJECT_CACHE_KEY_FUNC',
#     'DEFAULT_LIST_CACHE_KEY_FUNC',
#     'DEFAULT_ETAG_FUNC',
#     'DEFAULT_OBJECT_ETAG_FUNC',
#     'DEFAULT_LIST_ETAG_FUNC',
#     # API - ETAG
#     'DEFAULT_API_OBJECT_ETAG_FUNC',
#     'DEFAULT_API_LIST_ETAG_FUNC',
# ]
# 
# Path: rest_framework_extensions/utils.py
# def get_rest_framework_version():
# def flatten(list_of_lists):
# def prepare_header_name(name):
# def get_unique_method_id(view_instance, view_method):
# def get_model_opts_concrete_fields(opts):
# def compose_parent_pk_kwarg_name(value):
# 
# Path: tests_app/tests/functional/mixins/list_update_model_mixin/models.py
# class CommentForListUpdateModelMixin(models.Model):
#     email = models.EmailField()
# 
# class UserForListUpdateModelMixin(models.Model):
#     email = models.EmailField()
#     name = models.CharField(max_length=10)
#     age = models.IntegerField()
#     last_name = models.CharField(max_length=10)
#     password = models.CharField(max_length=100)
# 
# Path: tests_app/testutils.py
# def override_extensions_api_settings(**kwargs):
#     return patch.multiple(
#         'rest_framework_extensions.settings.extensions_api_settings',
#         **kwargs
#     )


# Path: tests_app/tests/functional/mixins/list_update_model_mixin/tests.py
import json
import unittest
import django
from django.test import override_settings
from rest_framework.test import APITestCase
from rest_framework_extensions.settings import extensions_api_settings
from rest_framework_extensions import utils
from .models import (
    CommentForListUpdateModelMixin as Comment,
    UserForListUpdateModelMixin as User
)
from tests_app.testutils import override_extensions_api_settings

        self.assertEqual(resp.status_code, 204)
        for comment in Comment.objects.all():
            self.assertEqual(comment.email, self.patch_data['email'])

    def test_bulk_partial_update__should_update_filtered_queryset(self):
        resp = self.client.patch('/comments/?id=1', data=json.dumps(self.patch_data), content_type='application/json', **self.protection_headers)
        self.assertEqual(resp.status_code, 204)
        self.assertEqual(Comment.objects.get(pk=1).email, self.patch_data['email'])
        self.assertEqual(Comment.objects.get(pk=2).email, self.comments[1].email)

    def test_bulk_partial_update__should_not_update_if_client_has_no_permissions(self):
        resp = self.client.patch('/comments-with-permission/', data=json.dumps(self.patch_data), content_type='application/json', **self.protection_headers)
        self.assertEqual(resp.status_code, 404)
        for i, comment in enumerate(Comment.objects.all()):
            self.assertEqual(comment.email, self.comments[i].email)


@override_settings(ROOT_URLCONF='tests_app.tests.functional.mixins.list_update_model_mixin.urls')
class ListUpdateModelMixinTestBehaviour__serializer_fields(APITestCase):

    def setUp(self):
        self.user = User.objects.create(
            id=1,
            name='Gennady',
            age=24,
            last_name='Chibisov',
            email='example@ya.ru',
            password='somepassword'
        )
        self.headers = {

            utils.prepare_header_name(extensions_api_settings.DEFAULT_BULK_OPERATION_HEADER_NAME): 'true'