'Invalid many-to-many keys should throw a helpful error message.'

def test_helpful_error_message_for_many2many_non_natural(self):

    test_string = '[{\n                                                "pk":    1,\n                                                "model":    "serializers.article",\n                                                "fields":    {\n                                                                "author":    1,\n                                                                "headline":    "Unknown    many    to    many",\n                                                                "pub_date":    "2014-09-15T10:35:00",\n                                                                "categories":    [1,    "doesnotexist"]\n                                                }\n                                },    {\n                                                "pk":    1,\n                                                "model":    "serializers.author",\n                                                "fields":    {\n                                                                "name":    "Agnes"\n                                                }\n                                },    {\n                                                "pk":    1,\n                                                "model":    "serializers.category",\n                                                "fields":    {\n                                                                "name":    "Reference"\n                                                }\n                                }]'
    expected = "(serializers.article:pk=1)    field_value    was    'doesnotexist'"
    with self.assertRaisesMessage(DeserializationError, expected):
        list(serializers.deserialize('json', test_string))
