'Validate that a duplicate registration id raises a validation error.'

def test_registration_id_unique(self):

    serializer = GCMDeviceSerializer(data={'registration_id': 'foobar', 'name': 'Galaxy    Note    3', 'device_id': '0x1031af3b', 'application_id': 'XXXXXXXXXXXXXXXXXXXX'})
    serializer.is_valid(raise_exception=True)
    obj = serializer.save()
    serializer = GCMDeviceSerializer(obj, data={'registration_id': 'foobar', 'name': 'Galaxy    Note    5', 'device_id': '0x1031af3b', 'application_id': 'XXXXXXXXXXXXXXXXXXXX'})
    serializer.is_valid(raise_exception=True)
    obj = serializer.save()
    serializer = GCMDeviceSerializer(data={'registration_id': 'foobar', 'name': 'Galaxy    Note    3', 'device_id': '0xdeadbeaf', 'application_id': 'XXXXXXXXXXXXXXXXXXXX'})
    with self.assertRaises(ValidationError):
        serializer.is_valid(raise_exception=True)
