# 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
        }
        resp = self.client.put('/comments/1/', data=json.dumps(data), content_type='application/json')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(Comment.objects.get(pk=1).email, 'example@yandex.ru')

    def test_partial_update_instance(self):
        data = {
            'id': 1,
            'email': 'example@yandex.ru'
        }
        resp = self.client.patch('/comments/1/', data=json.dumps(data), content_type='application/json')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(Comment.objects.get(pk=1).email, 'example@yandex.ru')

    def test_bulk_partial_update__without_protection_header(self):
        resp = self.client.patch('/comments/', data=json.dumps(self.patch_data), content_type='application/json')
        self.assertEqual(resp.status_code, 400)
        expected_message = {
            'detail': 'Header \'{0}\' should be provided for bulk operation.'.format(
                extensions_api_settings.DEFAULT_BULK_OPERATION_HEADER_NAME
            )
        }
        self.assertEqual(resp.data, expected_message)

    def test_bulk_partial_update__with_protection_header(self):
        resp = self.client.patch('/comments/', data=json.dumps(self.patch_data), content_type='application/json', **self.protection_headers)
        self.assertEqual(resp.status_code, 204)
        for comment in Comment.objects.all():
            self.assertEqual(comment.email, self.patch_data['email'])


# 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

        }
        resp = self.client.put('/comments/1/', data=json.dumps(data), content_type='application/json')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(Comment.objects.get(pk=1).email, 'example@yandex.ru')

    def test_partial_update_instance(self):
        data = {
            'id': 1,
            'email': 'example@yandex.ru'
        }
        resp = self.client.patch('/comments/1/', data=json.dumps(data), content_type='application/json')
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(Comment.objects.get(pk=1).email, 'example@yandex.ru')

    def test_bulk_partial_update__without_protection_header(self):
        resp = self.client.patch('/comments/', data=json.dumps(self.patch_data), content_type='application/json')
        self.assertEqual(resp.status_code, 400)
        expected_message = {
            'detail': 'Header \'{0}\' should be provided for bulk operation.'.format(
                extensions_api_settings.DEFAULT_BULK_OPERATION_HEADER_NAME
            )
        }
        self.assertEqual(resp.data, expected_message)

    def test_bulk_partial_update__with_protection_header(self):
        resp = self.client.patch('/comments/', data=json.dumps(self.patch_data), content_type='application/json', **self.protection_headers)
        self.assertEqual(resp.status_code, 204)
        for comment in Comment.objects.all():
            self.assertEqual(comment.email, self.patch_data['email'])


    @override_extensions_api_settings(DEFAULT_BULK_OPERATION_HEADER_NAME=None)