File: test_client_token.py

package info (click to toggle)
python-braintree 3.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,376 kB
  • ctags: 1,998
  • sloc: python: 13,634; makefile: 73; sh: 8
file content (23 lines) | stat: -rw-r--r-- 891 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
import json
from tests.test_helper import *

class TestClientToken(unittest.TestCase):
    def test_credit_card_options_require_customer_id(self):
        for option in ["verify_card", "make_default", "fail_on_duplicate_payment_method"]:
            try:
                client_token = ClientToken.generate({
                    "options": {option: True}
                })
                self.assertTrue(False, "Should have raised an exception")
            except InvalidSignatureError as e:
                self.assertTrue(str(e).find(option))

    def test_generate_delegates_client_token_generation_to_gateway(self):
        class MockGateway():
            def generate(self, _):
                return "mock_client_token"

        mock_gateway = MockGateway()
        client_token = ClientToken.generate({}, mock_gateway)

        self.assertEqual("mock_client_token", client_token)