File: test_apple_pay_gateway.py

package info (click to toggle)
python-braintree 4.31.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,576 kB
  • sloc: python: 28,946; makefile: 9; sh: 8
file content (27 lines) | stat: -rw-r--r-- 1,525 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from tests.test_helper import *
from braintree.apple_pay_gateway import ApplePayGateway
from unittest.mock import MagicMock

class TestApplePayGateway(unittest.TestCase):
    @staticmethod
    def setup_apple_pay_gateway_and_mock_http():
        braintree_gateway = BraintreeGateway(Configuration.instantiate())
        apple_pay_gateway = ApplePayGateway(braintree_gateway)
        http_mock = MagicMock(name='config.http')
        braintree_gateway.config.http = http_mock
        return apple_pay_gateway, http_mock

    def test_registered_domains(self):
        apple_pay_gateway, http_mock = self.setup_apple_pay_gateway_and_mock_http()
        apple_pay_gateway.registered_domains()
        self.assertTrue("get('/merchants/integration_merchant_id/processing/apple_pay/registered_domains')" in str(http_mock.mock_calls))

    def test_register_domain(self):
        apple_pay_gateway, http_mock = self.setup_apple_pay_gateway_and_mock_http()
        apple_pay_gateway.register_domain('test.example.com')
        self.assertTrue("post('/merchants/integration_merchant_id/processing/apple_pay/validate_domains', {'url': 'test.example.com'})" in str(http_mock.mock_calls))

    def test_unregister_domain(self):
        apple_pay_gateway, http_mock = self.setup_apple_pay_gateway_and_mock_http()
        apple_pay_gateway.unregister_domain('test.example.com')
        self.assertTrue("delete('/merchants/integration_merchant_id/processing/apple_pay/unregister_domain?url=test.example.com')" in str(http_mock.mock_calls))