Revert "Fix also in fields_to_partial_json"

This reverts commit c74a18e9e3.
This commit is contained in:
Adrien Ferrand 2020-03-12 22:39:04 +01:00
parent 8c7a9e05a6
commit 7faa379fb9

View file

@ -30,13 +30,13 @@ class ResourceMixin(VersionedLEACMEMixin):
"""
def to_partial_json(self):
"""See josepy.JSONDeserializable.to_partial_json()"""
return _safe_jobj_compliance(super(ResourceMixin, self),
'to_partial_json', 'resource')
if hasattr(super(ResourceMixin, self), 'to_partial_json'):
jobj = super(ResourceMixin, self).to_partial_json() # type: ignore
if self.le_acme_version == 2:
jobj.pop('resource', None)
return jobj
def fields_to_partial_json(self):
"""See josepy.JSONDeserializable.fields_to_partial_json()"""
return _safe_jobj_compliance(super(ResourceMixin, self),
'fields_to_partial_json', 'resource')
raise AttributeError('Method to_partial_json() is not implemented.') # pragma: no cover
class TypeMixin(VersionedLEACMEMixin):
@ -46,20 +46,10 @@ class TypeMixin(VersionedLEACMEMixin):
"""
def to_partial_json(self):
"""See josepy.JSONDeserializable.to_partial_json()"""
return _safe_jobj_compliance(super(TypeMixin, self),
'to_partial_json', 'type')
if hasattr(super(TypeMixin, self), 'to_partial_json'):
jobj = super(TypeMixin, self).to_partial_json() # type: ignore
if self.le_acme_version == 2:
jobj.pop('type', None)
return jobj
def fields_to_partial_json(self):
"""See josepy.JSONDeserializable.fields_to_partial_json()"""
return _safe_jobj_compliance(super(TypeMixin, self),
'fields_to_partial_json', 'type')
def _safe_jobj_compliance(instance, jobj_method, uncompliant_field):
if hasattr(instance, jobj_method):
jobj = getattr(instance, jobj_method)()
if instance.le_acme_version:
jobj.pop(uncompliant_field, None)
return jobj
raise AttributeError('Method {0}() is not implemented.'.format(jobj_method)) # pragma: no cover
raise AttributeError('Method to_partial_json() is not implemented.') # pragma: no cover