def test_omit_none(): assert omit_none({ 'foo': None, 'baz': 'bat', 'qux': None, 'flan': 0 }) == { 'baz': 'bat', 'flan': 0 } assert omit_none(dict((k, None) for k in ('qux', 'quux', 'quuux'))) == {} assert omit_none({'nope': 'yep'}) == {'nope': 'yep'} assert omit_none({}) == {}
def add_listing(self, release, condition, price, status, sleeve_condition=None, comments=None, allow_offers=None, external_id=None, location=None, weight=None, format_quantity=None): release_id = release.id if isinstance(release, Release) else release data = { "release_id": str(release_id), "condition": condition, "sleeve_condition": sleeve_condition, "price": price, "comments": comments, "allow_offers": allow_offers, "status": status, "external_id": external_id, "location": location, "weight": weight, "format_quantity": format_quantity, } self.client._post(self.client._base_url + '/marketplace/listings', omit_none(data)) self._invalidate()
def add(self, message=None, status=None, email_buyer=True, email_seller=False): data = { 'message': message, 'status': status, 'email_buyer': email_buyer, 'email_seller': email_seller, } self.client._post(self.url, omit_none(data)) self._invalidate()
def add(self, release, notes=None, notes_public=None, rating=None): release_id = release.id if isinstance(release, Release) else release data = { 'release_id': str(release_id), 'notes': notes, 'notes_public': notes_public, 'rating': rating, } self.client._put(self.url + '/' + str(release_id), omit_none(data)) self._invalidate()