diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0be50bfea..3b5dd5caf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,7 +79,7 @@ jobs: matrix: python_version: # The last ~5 versions, once we're on schedule - # https://docs.stripe.com/sdks/versioning?server=python#stripe-sdk-language-version-support-policy + # https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy - "3.7" - "3.8" - "3.9" diff --git a/CHANGELOG.md b/CHANGELOG.md index 1988a9af4..ba5a07c26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,7 +125,7 @@ This release changes the pinned API version to `2025-09-30.clover` and contains * [#1569](https://github.com/stripe/stripe-python/pull/1569) Renamed Urllib2Client to UrllibClient - ⚠️ Rename `http_client.Urllib2Client` to `http_client.UrllibClient` as Python `urllib2` was renamed to `urllib` in Python 3. * [#1606](https://github.com/stripe/stripe-python/pull/1606) ⚠️ drop support for Python 3.6 & clarify version policy - - Read our new [language version support policy](https://docs.stripe.com/sdks/versioning?server=python#stripe-sdk-language-version-support-policy) + - Read our new [language version support policy](https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy) - ⚠️ In this release, we drop support for Python 3.6 - Support for Python 3.7 is deprecated and will be removed in the next scheduled major release (March 2026) * [#1596](https://github.com/stripe/stripe-python/pull/1596) ⚠️ Unify resource and service method parameters into one class diff --git a/README.md b/README.md index f4c8b6b3c..b24cbd48c 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ python -m pip install . ### Requirements -Per our [Language Version Support Policy](https://docs.stripe.com/sdks/versioning?server=python#stripe-sdk-language-version-support-policy), we currently support **Python 3.7+**. +Per our [Language Version Support Policy](https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy), we currently support **Python 3.7+**. -Support for Python 3.7 and 3.8 is deprecated and will be removed in an upcoming major version. Read more and see the full schedule in the docs: https://docs.stripe.com/sdks/versioning?server=python#stripe-sdk-language-version-support-policy +Support for Python 3.7 and 3.8 is deprecated and will be removed in an upcoming major version. Read more and see the full schedule in the docs: https://docs.stripe.com/sdks/versioning?lang=python#stripe-sdk-language-version-support-policy #### Extended Support diff --git a/tests/api_resources/test_promotion_code.py b/tests/api_resources/test_promotion_code.py deleted file mode 100644 index 0a10c5c2b..000000000 --- a/tests/api_resources/test_promotion_code.py +++ /dev/null @@ -1,49 +0,0 @@ -import stripe - - -TEST_RESOURCE_ID = "promo_123" - - -class TestPromotionCode(object): - def test_is_listable(self, http_client_mock): - resources = stripe.PromotionCode.list() - http_client_mock.assert_requested("get", path="/v1/promotion_codes") - assert isinstance(resources.data, list) - assert isinstance(resources.data[0], stripe.PromotionCode) - - def test_is_retrievable(self, http_client_mock): - resource = stripe.PromotionCode.retrieve(TEST_RESOURCE_ID) - http_client_mock.assert_requested( - "get", path="/v1/promotion_codes/%s" % TEST_RESOURCE_ID - ) - assert isinstance(resource, stripe.PromotionCode) - - def test_is_creatable(self, http_client_mock): - resource = stripe.PromotionCode.create(coupon="co_123", code="MYCODE") - http_client_mock.assert_requested( - "post", - path="/v1/promotion_codes", - post_data="code=MYCODE&coupon=co_123", - ) - assert isinstance(resource, stripe.PromotionCode) - - def test_is_saveable(self, http_client_mock): - resource = stripe.PromotionCode.retrieve(TEST_RESOURCE_ID) - resource.metadata["key"] = "value" - resource.save() - http_client_mock.assert_requested( - "post", - path="/v1/promotion_codes/%s" % TEST_RESOURCE_ID, - post_data="metadata[key]=value", - ) - - def test_is_modifiable(self, http_client_mock): - resource = stripe.PromotionCode.modify( - TEST_RESOURCE_ID, metadata={"key": "value"} - ) - http_client_mock.assert_requested( - "post", - path="/v1/promotion_codes/%s" % TEST_RESOURCE_ID, - post_data="metadata[key]=value", - ) - assert isinstance(resource, stripe.PromotionCode) diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index 17d29c42d..c36b3682d 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -23327,6 +23327,109 @@ async def test_promotion_codes_get_2_service_async( def test_promotion_codes_post_service_non_namespaced( self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "post", + "/v1/promotion_codes", + ) + client = StripeClient( + "sk_test_123", + http_client=http_client_mock.get_mock_http_client(), + ) + + client.promotion_codes.create( + { + "promotion": {"type": "coupon", "coupon": "Z4OV52SU"}, + } + ) + http_client_mock.assert_requested( + "post", + path="/v1/promotion_codes", + query_string="", + api_base="https://api.stripe.com", + post_data="promotion[type]=coupon&promotion[coupon]=Z4OV52SU", + ) + + def test_promotion_codes_post( + self, http_client_mock: HTTPClientMock + ) -> None: + stripe.PromotionCode.create( + promotion={"type": "coupon", "coupon": "Z4OV52SU"}, + ) + http_client_mock.assert_requested( + "post", + path="/v1/promotion_codes", + query_string="", + post_data="promotion[type]=coupon&promotion[coupon]=Z4OV52SU", + ) + + def test_promotion_codes_post_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "post", + "/v1/promotion_codes", + ) + client = StripeClient( + "sk_test_123", + http_client=http_client_mock.get_mock_http_client(), + ) + + client.v1.promotion_codes.create( + { + "promotion": {"type": "coupon", "coupon": "Z4OV52SU"}, + } + ) + http_client_mock.assert_requested( + "post", + path="/v1/promotion_codes", + query_string="", + api_base="https://api.stripe.com", + post_data="promotion[type]=coupon&promotion[coupon]=Z4OV52SU", + ) + + @pytest.mark.anyio + async def test_promotion_codes_post_async( + self, http_client_mock: HTTPClientMock + ) -> None: + await stripe.PromotionCode.create_async( + promotion={"type": "coupon", "coupon": "Z4OV52SU"}, + ) + http_client_mock.assert_requested( + "post", + path="/v1/promotion_codes", + query_string="", + post_data="promotion[type]=coupon&promotion[coupon]=Z4OV52SU", + ) + + @pytest.mark.anyio + async def test_promotion_codes_post_service_async( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "post", + "/v1/promotion_codes", + ) + client = StripeClient( + "sk_test_123", + http_client=http_client_mock.get_mock_http_client(), + ) + + await client.v1.promotion_codes.create_async( + { + "promotion": {"type": "coupon", "coupon": "Z4OV52SU"}, + } + ) + http_client_mock.assert_requested( + "post", + path="/v1/promotion_codes", + query_string="", + api_base="https://api.stripe.com", + post_data="promotion[type]=coupon&promotion[coupon]=Z4OV52SU", + ) + + def test_promotion_codes_post_2_service_non_namespaced( + self, http_client_mock: HTTPClientMock ) -> None: http_client_mock.stub_request( "post", @@ -23349,7 +23452,7 @@ def test_promotion_codes_post_service_non_namespaced( post_data="metadata[order_id]=6735", ) - def test_promotion_codes_post( + def test_promotion_codes_post_2( self, http_client_mock: HTTPClientMock ) -> None: stripe.PromotionCode.modify( @@ -23363,7 +23466,7 @@ def test_promotion_codes_post( post_data="metadata[order_id]=6735", ) - def test_promotion_codes_post_service( + def test_promotion_codes_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: http_client_mock.stub_request( @@ -23388,7 +23491,7 @@ def test_promotion_codes_post_service( ) @pytest.mark.anyio - async def test_promotion_codes_post_async( + async def test_promotion_codes_post_2_async( self, http_client_mock: HTTPClientMock ) -> None: await stripe.PromotionCode.modify_async( @@ -23403,7 +23506,7 @@ async def test_promotion_codes_post_async( ) @pytest.mark.anyio - async def test_promotion_codes_post_service_async( + async def test_promotion_codes_post_2_service_async( self, http_client_mock: HTTPClientMock ) -> None: http_client_mock.stub_request(