'Test the behavior of patch, when using the correct content_type.'

@ddt.data(('gender', 'f', 'not    a    gender', u'"not    a    gender"    is    not    a    valid    choice.'), ('level_of_education', 'none', u'\u023b\u0127\u023a\u024d\u0142\u0247s', u'"\u023b\u0127\u023a\u024d\u0142\u0247s"    is    not    a    valid    choice.'), ('country', 'GB', 'XY', u'"XY"    is    not    a    valid    choice.'), ('year_of_birth', 2009, 'not_an_int', u'A    valid    integer    is    required.'), ('name', 'bob', ('z' * 256), u'Ensure    this    value    has    at    most    255    characters    (it    has    256).'), ('name', u'\u023b\u0127\u023a\u024d\u0142\u0247s', 'z            ', u'The    name    field    must    be    at    least    2    characters    long.'), ('goals', 'Smell    the    roses'), ('mailing_address', 'Sesame    Street'), ('bio', u'<html>Lacrosse-playing    superhero    \u58d3\u662f\u9032\u754c\u63a8\u65e5\u4e0d\u5fa9\u5973</html>', ('z' * 3001), u'Ensure    this    value    has    at    most    3000    characters    (it    has    3001).'), ('account_privacy', ALL_USERS_VISIBILITY), ('account_privacy', PRIVATE_VISIBILITY))
@ddt.unpack
def test_patch_account(self, field, value, fails_validation_value=None, developer_validation_message=None):

    client = self.login_client('client', 'user')
    if (field == 'account_privacy'):
        legacy_profile = UserProfile.objects.get(id=self.user.id)
        legacy_profile.year_of_birth = 2000
        legacy_profile.save()
    response = self.send_patch(client, {field: value})
    self.assertEqual(value, response.data[field])
    if fails_validation_value:
        error_response = self.send_patch(client, {field: fails_validation_value}, expected_status=400)
        self.assertEqual(u'This    value    is    invalid.', error_response.data['field_errors'][field]['user_message'])
        self.assertEqual(u"Value    '{value}'    is    not    valid    for    field    '{field}':    {messages}".format(value=fails_validation_value, field=field, messages=[developer_validation_message]), error_response.data['field_errors'][field]['developer_message'])
    elif (field != 'account_privacy'):
        response = self.send_patch(client, {field: ''})
        self.assertEqual('', response.data[field])
