From 259eeb27ea3a9658c673d762064e90bd771d933f Mon Sep 17 00:00:00 2001 From: Aaron Crespo Date: Wed, 16 Jun 2021 11:44:04 -0400 Subject: [PATCH] phased release refinements --- README.md | 4 ++-- asconnect/models/app_store.py | 2 +- asconnect/version_client.py | 18 +++++++++++---- tests/test_asconnect.py | 43 ++++++++++++++++++++++++++++++----- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6a79159..96e75c1 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,8 @@ It's that easy. Most of the time at least. If you don't have previous version to # Create a new version version = client.app.create_new_version(version="1.2.3", app_id=app.identifier) -# Start a versions' phased release -phased_release = client.version.create_phased_release(version_id=version.identifier, phased_release_state=PhasedReleaseState.active) +# Start a versions' phased release, the initial state of which is INACTIVE +phased_release = client.version.create_phased_release(version_id=version.identifier) # Check on a phased release phased_release = client.version.get_phased_release(version_id=version.identifier) diff --git a/asconnect/models/app_store.py b/asconnect/models/app_store.py index 05f2795..dc4af45 100644 --- a/asconnect/models/app_store.py +++ b/asconnect/models/app_store.py @@ -27,7 +27,7 @@ class ReleaseType(enum.Enum): class PhasedReleaseState(enum.Enum): """App store phased release state. - inactive: TODO(?) default state + inactive: initial state active: over the course of 7 days the app will be rolled out in randomly selected phases paused: the rollout is paused complete: the rollout is complete diff --git a/asconnect/version_client.py b/asconnect/version_client.py index 94f056f..1db748d 100755 --- a/asconnect/version_client.py +++ b/asconnect/version_client.py @@ -96,7 +96,11 @@ class VersionClient: """ return next_or_none(self.get_all(app_id=app_id, version_string=version_string)) - def get_phased_release(self, *, version_id: str,) -> Optional[AppStoreVersionPhasedRelease]: + def get_phased_release( + self, + *, + version_id: str, + ) -> Optional[AppStoreVersionPhasedRelease]: """Get the phased release of given app version :param version_id: The version ID to query for phased releases @@ -128,17 +132,21 @@ class VersionClient: endpoint="appStoreVersionPhasedReleases", data={ "data": { - "attributes": {"phasedReleaseState": phased_release_state}, + "attributes": {"phasedReleaseState": phased_release_state.value}, "type": "appStoreVersionPhasedReleases", "relationships": { - "appStoreVersion": {"id": version_id, "type": "appStoreVersions"} + "appStoreVersion": {"data": {"id": version_id, "type": "appStoreVersions"}} }, } }, data_type=AppStoreVersionPhasedRelease, ) - def delete_phased_release(self, *, phased_release_id: str,) -> None: + def delete_phased_release( + self, + *, + phased_release_id: str, + ) -> None: """Delete a Phased Release :param phased_release_id: The ID of the release set to delete @@ -165,7 +173,7 @@ class VersionClient: endpoint=f"appStoreVersionPhasedReleases/{phased_release_id}", data={ "data": { - "attributes": {"phasedReleaseState": phased_release_state}, + "attributes": {"phasedReleaseState": phased_release_state.value}, "type": "appStoreVersionPhasedReleases", "id": phased_release_id, } diff --git a/tests/test_asconnect.py b/tests/test_asconnect.py index 824d0d0..452395e 100644 --- a/tests/test_asconnect.py +++ b/tests/test_asconnect.py @@ -10,6 +10,16 @@ import re import sys from typing import Optional, Tuple, Union +from asconnect.models import ( + AppStoreVersion, + AppStoreVersionPhasedRelease, + PhasedReleaseState, + Platform, + AppStoreVersionLocalization, + AppStoreReviewDetails, + IdfaDeclaration, +) + import jwt sys.path.insert(0, os.path.abspath(os.path.join(os.path.abspath(__file__), "..", ".."))) @@ -358,6 +368,26 @@ def test_create_new_version() -> None: client.app.create_new_version(version="1.2.3", app_id=app.identifier) +def test_create_new_phased_release() -> None: + """Test that we can create a new app store version.""" + key_id, key_contents, issuer_id = get_test_data() + + client = asconnect.Client( + key_id=key_id, + key_contents=key_contents, + issuer_id=issuer_id, + ) + + app = client.app.get_from_bundle_id(APP_ID) + assert app is not None + + version = client.app.create_new_version(version="1.2.3", app_id=app.identifier) + release = client.version.create_phased_release(version_id=version.identifier) + + assert release is not None + assert release.attributes.phased_release_state.value is "INACTIVE" + + def test_get_versions() -> None: """Test that we can get app store versions.""" key_id, key_contents, issuer_id = get_test_data() @@ -766,22 +796,23 @@ def test_get_versions_phased_release() -> None: """Test that we can get a specific app store version.""" key_id, key_contents, issuer_id = get_test_data() - client = asconnect.Client(key_id=key_id, key_contents=key_contents, issuer_id=issuer_id,) + client = asconnect.Client( + key_id=key_id, + key_contents=key_contents, + issuer_id=issuer_id, + ) app = client.app.get_from_bundle_id(APP_ID) assert app is not None - version = client.version.get_version(app_id=app.identifier, version_string="4.2122.0") + version = client.version.get_version(app_id=app.identifier, version_string="1.2.3") assert version is not None release = client.version.get_phased_release(version_id=version.identifier) assert release is not None - assert release.attributes.phased_release_state is not None - - # Phased releases always belong to a release there is no GET v1/appStoreVersionPhasedRelease/{id} - # Only PATCH v1/appStoreVersionPhasedRelease/{id} exists + assert release.attributes.phased_release_state is not Nones def load_value(