File: test_ephemeral_key.py

package info (click to toggle)
python-stripe 12.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,864 kB
  • sloc: python: 157,573; makefile: 13; sh: 9
file content (40 lines) | stat: -rw-r--r-- 1,365 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
28
29
30
31
32
33
34
35
36
37
38
39
40
import pytest

import stripe


class TestEphemeralKey(object):
    def test_is_creatable(self, http_client_mock):
        resource = stripe.EphemeralKey.create(
            customer="cus_123", stripe_version="2017-05-25"
        )
        http_client_mock.assert_requested(
            "post",
            path="/v1/ephemeral_keys",
            stripe_version="2017-05-25",
            post_data="customer=cus_123",
        )
        assert isinstance(resource, stripe.EphemeralKey)

    def test_is_not_creatable_without_an_explicit_api_version(self):
        with pytest.raises(
            ValueError, match="stripe_version must be specified"
        ):
            stripe.EphemeralKey.create(customer="cus_123")

    def test_is_deletable(self, http_client_mock):
        resource = stripe.EphemeralKey.create(
            customer="cus_123", stripe_version="2017-05-25"
        )
        resource.delete()
        http_client_mock.assert_requested(
            "delete", path="/v1/ephemeral_keys/%s" % resource.id
        )
        assert isinstance(resource, stripe.EphemeralKey)

    def test_can_delete(self, http_client_mock):
        resource = stripe.EphemeralKey.delete("ephkey_123")
        http_client_mock.assert_requested(
            "delete", path="/v1/ephemeral_keys/ephkey_123"
        )
        assert isinstance(resource, stripe.EphemeralKey)