From e618c9d99e79cfc0254c6937d8546e6bd9f8b243 Mon Sep 17 00:00:00 2001 From: Przemyslaw Suliga Date: Fri, 10 Oct 2014 11:42:11 +0200 Subject: [PATCH 1/2] Added a regression test for expiry param equal to 'None'. For a not expiring item. --- tests/test_client.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_client.py b/tests/test_client.py index 4ff78eb..d60db70 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -85,6 +85,15 @@ def test_transaction_reference(self): use_jsevents=True, transaction_reference='123') + def test_get_web_url_has_no_none_params(self): + # item with expiry not set. + item = ItemDefinition(1, 'EUR20', 'DE19.0', 'http://help.me/', 'title') + url = self.lp.get_add_url(item) + self.assertFalse( + 'expiry%3DNone' in url, + 'expiry url param is "None". Should be omitted.', + ) + if __name__ == '__main__': unittest.main() From dad33414349ffc7f9479dbf5d9622132c4745a98 Mon Sep 17 00:00:00 2001 From: Przemyslaw Suliga Date: Fri, 10 Oct 2014 12:01:23 +0200 Subject: [PATCH 2/2] Discard `None` params in `LaterPayClient._get_web_url()` We don't want to create urls containing "param=None" bits if a param is optional. --- laterpay/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laterpay/__init__.py b/laterpay/__init__.py index 17f32ed..31afa7f 100644 --- a/laterpay/__init__.py +++ b/laterpay/__init__.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function -import copy import json import logging import random @@ -231,7 +230,8 @@ def _get_web_url(self, transaction_reference=None, consumable=False): - data = copy.copy(item_definition.data) + # filter out params with None value. + data = {k: v for k, v in item_definition.data.items() if v is not None} if use_jsevents: data['jsevents'] = 1