def test_validate_value_fail_denied_acces_other_user_space(self): """ Test whether overriden validate_value method raises a serializers.ValidationError when user tries to access another user's space. """ path_parm_serializer = PathParameterSerializer(user=self.user) with self.assertRaises(serializers.ValidationError): value = "{}/uploads, anotheruser".format(self.username) path_parm_serializer.validate_value(value) with self.assertRaises(serializers.ValidationError): value = "{}, anotheruser/uploads".format(self.username, self.username) path_parm_serializer.validate_value(value)