def serializers(self): available_serializers = serializers.gather( self.store.translation_project.project.__class__) found_serializers = [] for serializer in self.project_serializers: found_serializers.append(available_serializers[serializer]) return found_serializers
def test_moz_ios(): ios_serializers = serializers.gather(Store) assert "ios" in ios_serializers assert ios_serializers["ios"] is IOSSerializer ios_deserializers = deserializers.gather(Store) assert "ios" in ios_deserializers assert ios_deserializers["ios"] is IOSDeserializer
def handle(self, **kwargs): model = self.model_from_content_type(kwargs["model"]) if kwargs["deserializers"]: return self.print_serializers_list( deserializers.gather(model), serializer_type="deserializers") return self.print_serializers_list( serializers.gather(model))
def serializer_should_not_be_saved(**kwargs): if kwargs["key"] == "pootle.core.serializers": if not isinstance(kwargs["value"], list): return ValidationError("pootle.core.serializers must be a list") available_serializers = serializers.gather(kwargs["sender"]).keys() for k in kwargs["value"]: if k not in available_serializers: return ValidationError("Unrecognised pootle.core.serializers: '%s'" % k) elif kwargs["key"] == "pootle.core.deserializers": if not isinstance(kwargs["value"], list): return ValidationError("pootle.core.deserializers must be a list") available_deserializers = deserializers.gather(kwargs["sender"]).keys() for k in kwargs["value"]: if k not in available_deserializers: return ValidationError("Unrecognised pootle.core.deserializers: '%s'" % k)
def _test_serializer_list(out, err, model=None): NO_SERIALS = "There are no serializers set up on your system" serials = serializers.gather(model) expected = [] if not serials.keys(): expected.append(NO_SERIALS) if serials.keys(): heading = "Serializers" expected.append("\n%s" % heading) expected.append("-" * len(heading)) for name, klass in serials.items(): expected.append("{!s: <30} {!s: <50} ".format(name, klass)) assert out == "%s\n" % ("\n".join(expected))
def serializer_should_not_be_saved(**kwargs): if kwargs["key"] == "pootle.core.serializers": if not isinstance(kwargs["value"], list): return ValidationError("pootle.core.serializers must be a list") available_serializers = serializers.gather(kwargs["sender"]).keys() for k in kwargs["value"]: if k not in available_serializers: return ValidationError( "Unrecognised pootle.core.serializers: '%s'" % k) elif kwargs["key"] == "pootle.core.deserializers": if not isinstance(kwargs["value"], list): return ValidationError("pootle.core.deserializers must be a list") available_deserializers = deserializers.gather(kwargs["sender"]).keys() for k in kwargs["value"]: if k not in available_deserializers: return ValidationError( "Unrecognised pootle.core.deserializers: '%s'" % k)