def test_umlaut_new_client_description(): """ Tests umlaut on description string. """ pm = MockPymill('key') pm.new_client(email="*****@*****.**", description='Ümläüt') assert pm.api_called assert pm.call_args['params'].get('description') == 'Ümläüt'
def test_umlaut_update_client_description(): """ Tests umlaut on description string. """ pm = MockPymill('key') clientid = "client_12345" pm.update_client(client_id = clientid, email="*****@*****.**", description='Ümläüt') assert pm.api_called assert pm.call_args['params'].get('description') == 'Ümläüt'
def test_umlaut_update_client_description(): """ Tests umlaut on description string. """ pm = MockPymill('key') clientid = "client_12345" pm.update_client(client_id=clientid, email="*****@*****.**", description='Ümläüt') assert pm.api_called assert pm.call_args['params'].get('description') == 'Ümläüt'
def test_transact_requirements_with_preauth(): """ Required parameters: * preauth * amount * currency """ pm = MockPymill('key') pm.transact(preauth="preauth", amount=123, currency='EUR') assert pm.api_called assert pm.call_args['params'].get('preauthorization') == 'preauth'
def test_offer_intervals(): """ Tests for correct intervals. From API documentation: ``Format: number DAY|WEEK|MONTH|YEAR Example: 2 DAY`` """ params = {'amount': 100, 'currency': 'EUR', 'name': "NAME"} pm = MockPymill('key') for value in ('month', '1 year', '10 day', '2 week'): pm.new_offer(interval=value, **params) assert pm.api_called assert pm.call_args['params'].get('interval') == value
def test_transact_requirements_with_token(): """ Tests that all requirement checks work for calls using a token. In this case following parameters have to be passed in order to create a transaction: * token * amount * currency """ pm = MockPymill('key') pm.transact(token="token", amount=123, currency='EUR') assert pm.api_called assert pm.call_args['params'].get('token') == 'token'
def test_offer_requirements(): """ Tests that all requirement checks work creation of offers. Following parameters have to be passed in order to create an offer: * amount * interval * currency * name """ pm = MockPymill('key') pm.new_offer(interval="1 month", amount=123, currency='EUR', name="NAME") assert pm.api_called assert pm.call_args['params'].get('interval') == '1 month' assert pm.call_args['params'].get('amount') == '123' assert pm.call_args['params'].get('currency') == "EUR"
def test_offer_amount(): """ Tests that amount raises ValueErrors on false parameters. """ params = {'interval': "1 month", 'currency': 'EUR', 'name': "NAME"} pm = MockPymill('key') with pytest.raises(OfferException): pm.new_offer(amount='X', **params) with pytest.raises(OfferException): pm.new_offer(amount='10.1', **params) # FIXME: should raise an exception, too? pm.new_offer(amount=0, **params) assert pm.api_called == False # with correct value pm.new_offer(amount="100", **params) assert pm.api_called assert pm.call_args['params'].get('amount') == '100'
def test_offer_amount(): """ Tests that amount raises ValueErrors on false parameters. """ params = {'interval': "1 month", 'currency': 'EUR', 'name': "NAME"} pm = MockPymill('key') with pytest.raises(ValueError): pm.new_offer(amount='X', **params) with pytest.raises(ValueError): pm.new_offer(amount='10.1', **params) # FIXME: should raise an exception, too? pm.new_offer(amount=0, **params) assert pm.api_called == False # with correct value pm.new_offer(amount="100", **params) assert pm.api_called assert pm.call_args['params'].get('amount') == '100'
def test_transact_requirements_with_payment(): """ Required parameters: * payment (or account, code, holder, client) * amount * currency """ pm = MockPymill('key') pm.transact(payment='payment', amount=123, currency='EUR') assert pm.api_called pm = MockPymill('key') pm.transact(code='code', account='account', client='client', holder='holder', amount=123, currency='EUR') assert pm.api_called