| 1 |
import stripe |
| 2 |
|
| 3 |
|
| 4 |
TEST_RESOURCE_ID = "vs_123" |
| 5 |
|
| 6 |
|
| 7 |
class TestVerificationSession(object): |
| 8 |
def test_is_creatable(self, http_client_mock): |
| 9 |
resource = stripe.identity.VerificationSession.create(type="id_number") |
| 10 |
http_client_mock.assert_requested( |
| 11 |
"post", |
| 12 |
path="/v1/identity/verification_sessions", |
| 13 |
post_data="type=id_number", |
| 14 |
) |
| 15 |
assert isinstance(resource, stripe.identity.VerificationSession) |
| 16 |
|
| 17 |
def test_is_listable(self, http_client_mock): |
| 18 |
resources = stripe.identity.VerificationSession.list() |
| 19 |
http_client_mock.assert_requested( |
| 20 |
"get", path="/v1/identity/verification_sessions" |
| 21 |
) |
| 22 |
assert isinstance(resources.data, list) |
| 23 |
assert isinstance( |
| 24 |
resources.data[0], stripe.identity.VerificationSession |
| 25 |
) |
| 26 |
|
| 27 |
def test_is_modifiable(self, http_client_mock): |
| 28 |
resource = stripe.identity.VerificationSession.modify( |
| 29 |
TEST_RESOURCE_ID, metadata={"key": "value"} |
| 30 |
) |
| 31 |
http_client_mock.assert_requested( |
| 32 |
"post", |
| 33 |
path="/v1/identity/verification_sessions/%s" % TEST_RESOURCE_ID, |
| 34 |
post_data="metadata[key]=value", |
| 35 |
) |
| 36 |
assert isinstance(resource, stripe.identity.VerificationSession) |
| 37 |
|
| 38 |
def test_is_retrievable(self, http_client_mock): |
| 39 |
resource = stripe.identity.VerificationSession.retrieve( |
| 40 |
TEST_RESOURCE_ID |
| 41 |
) |
| 42 |
http_client_mock.assert_requested( |
| 43 |
"get", |
| 44 |
path="/v1/identity/verification_sessions/%s" % TEST_RESOURCE_ID, |
| 45 |
) |
| 46 |
assert isinstance(resource, stripe.identity.VerificationSession) |
| 47 |
|
| 48 |
def test_is_saveable(self, http_client_mock): |
| 49 |
resource = stripe.identity.VerificationSession.retrieve( |
| 50 |
TEST_RESOURCE_ID |
| 51 |
) |
| 52 |
resource.metadata["key"] = "value" |
| 53 |
verification_session = resource.save() |
| 54 |
http_client_mock.assert_requested( |
| 55 |
"post", |
| 56 |
path="/v1/identity/verification_sessions/%s" % TEST_RESOURCE_ID, |
| 57 |
post_data="metadata[key]=value", |
| 58 |
) |
| 59 |
assert isinstance(resource, stripe.identity.VerificationSession) |
| 60 |
assert resource is verification_session |
| 61 |
|
| 62 |
def test_can_cancel(self, http_client_mock): |
| 63 |
resource = stripe.identity.VerificationSession.retrieve( |
| 64 |
TEST_RESOURCE_ID |
| 65 |
) |
| 66 |
verification_session = resource.cancel() |
| 67 |
http_client_mock.assert_requested( |
| 68 |
"post", |
| 69 |
path="/v1/identity/verification_sessions/%s/cancel" |
| 70 |
% TEST_RESOURCE_ID, |
| 71 |
post_data="", |
| 72 |
) |
| 73 |
assert isinstance(resource, stripe.identity.VerificationSession) |
| 74 |
assert resource is verification_session |
| 75 |
|
| 76 |
def test_can_cancel_classmethod(self, http_client_mock): |
| 77 |
resource = stripe.identity.VerificationSession.cancel(TEST_RESOURCE_ID) |
| 78 |
http_client_mock.assert_requested( |
| 79 |
"post", |
| 80 |
path="/v1/identity/verification_sessions/%s/cancel" |
| 81 |
% TEST_RESOURCE_ID, |
| 82 |
post_data="", |
| 83 |
) |
| 84 |
assert isinstance(resource, stripe.identity.VerificationSession) |
| 85 |
|
| 86 |
def test_can_redact(self, http_client_mock): |
| 87 |
resource = stripe.identity.VerificationSession.retrieve( |
| 88 |
TEST_RESOURCE_ID |
| 89 |
) |
| 90 |
verification_session = resource.redact() |
| 91 |
http_client_mock.assert_requested( |
| 92 |
"post", |
| 93 |
path="/v1/identity/verification_sessions/%s/redact" |
| 94 |
% TEST_RESOURCE_ID, |
| 95 |
post_data="", |
| 96 |
) |
| 97 |
assert isinstance(resource, stripe.identity.VerificationSession) |
| 98 |
assert resource is verification_session |
| 99 |
|
| 100 |
def test_can_redact_classmethod(self, http_client_mock): |
| 101 |
resource = stripe.identity.VerificationSession.redact(TEST_RESOURCE_ID) |
| 102 |
http_client_mock.assert_requested( |
| 103 |
"post", |
| 104 |
path="/v1/identity/verification_sessions/%s/redact" |
| 105 |
% TEST_RESOURCE_ID, |
| 106 |
post_data="", |
| 107 |
) |
| 108 |
assert isinstance(resource, stripe.identity.VerificationSession) |