youknowone / itunes-iap

Apple iTunes In-app purchase verification tool
http://itunes-iap.readthedocs.io
Other
136 stars 50 forks source link

Make ObjectMapper inner dictionary writable #21

Closed stphivos closed 8 years ago

stphivos commented 8 years ago

Simplifies mocking of itunes receipt for unit testing. E.g.:

response = Response('json')
response.receipt.last_in_app['expires_date'] = 'expected date'
mock_verify.return_value = response
youknowone commented 8 years ago

In my opinion, this object should be read-only to prevent accidental misusage for products.

You need this feature to make easier to write test code in your product, right? Then how about adding helper function to patch ObjectMapper dynamically, like:

def ObjectMapper__setitem__(self, key, value):
      self._[key] = value
ObjectMapper.__setitem__ = __setitem__
stphivos commented 8 years ago

Yea sounds reasonable. I guess adding it dynamically for testing is not a bad idea, thanks.