Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing fields for App Store Connect models #383

Merged
merged 11 commits into from
Apr 26, 2024

Conversation

priitlatt
Copy link
Contributor

@priitlatt priitlatt commented Dec 19, 2023

Whenever App Store Connect API responses are converted to codemagic.apple.resources.App or codemagic.apple.resources.Build instances, then the logs get flooded with warning about unknown fields for attributes and relationships.

App warnings
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'subscriptionStatusUrl' for resource App.Attributes
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'subscriptionStatusUrlVersion' for resource App.Attributes
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'subscriptionStatusUrlForSandbox' for resource App.Attributes
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'subscriptionStatusUrlVersionForSandbox' for resource App.Attributes
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'appClips' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'appPricePoints' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'pricePoints' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'appPriceSchedule' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'appAvailability' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'appAvailabilityV2' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'subscriptionGroups' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'appCustomProductPages' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'inAppPurchasesV2' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'promotedPurchases' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'appEvents' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'reviewSubmissions' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'subscriptionGracePeriod' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'customerReviews' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'gameCenterDetail' for resource App.Relationships
[17:47:00 19-12-2023] WARNING resource.py:78 > Unknown field 'appStoreVersionExperimentsV2' for resource App.Relationships
Build warnings
[17:48:46 19-12-2023] WARNING resource.py:78 > Unknown field 'lsMinimumSystemVersion' for resource Build.Attributes
[17:48:46 19-12-2023] WARNING resource.py:78 > Unknown field 'computedMinMacOsVersion' for resource Build.Attributes
[17:48:46 19-12-2023] WARNING resource.py:78 > Unknown field 'computedMinVisionOsVersion' for resource Build.Attributes
[17:48:46 19-12-2023] WARNING resource.py:78 > Unknown field 'buildAudienceType' for resource Build.Attributes

Changes here add definitions for those fields.

@priitlatt priitlatt marked this pull request as ready for review April 24, 2024 08:09
Comment on lines +48 to +69
@pytest.fixture()
def app_store_connect(namespace_kwargs) -> AppStoreConnect:
args = AppStoreConnectArgument
if "TEST_APPLE_PRIVATE_KEY_PATH" in os.environ:
key_path = pathlib.Path(os.environ["TEST_APPLE_PRIVATE_KEY_PATH"])
private_key = key_path.expanduser().read_text()
key_identifier = os.environ["TEST_APPLE_KEY_IDENTIFIER"]
issuer_id = os.environ["TEST_APPLE_ISSUER_ID"]
elif "TEST_APPLE_PRIVATE_KEY_CONTENT" in os.environ:
private_key = os.environ["TEST_APPLE_PRIVATE_KEY_CONTENT"]
key_identifier = os.environ["TEST_APPLE_KEY_IDENTIFIER"]
issuer_id = os.environ["TEST_APPLE_ISSUER_ID"]
else:
raise RuntimeError("Missing App Store Connect authentication information")

ns = namespace_kwargs | {
args.ISSUER_ID.key: Types.IssuerIdArgument(issuer_id),
args.KEY_IDENTIFIER.key: Types.KeyIdentifierArgument(key_identifier),
args.PRIVATE_KEY.key: Types.PrivateKeyArgument(private_key),
}
cli_args = argparse.Namespace(**ns)
return AppStoreConnect.from_cli_args(cli_args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixture doesn't seem to be used anywhere in the codebase, can you elaborate what purpose it serves?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are quite right that as of now it is not used anywhere. But it is very useful for quickly testing out actual command invocations using tests instead of doing it from terminal with

python -m codemagic.toos.app_store_connect <action> <args> ...

I could add an example test which uses this fixture, but is skipped unless live API tests are enabled. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think let's add an example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 64ae629.

Comment on lines +13 to +16
def test_get_app(app_store_connect: AppStoreConnect):
app = app_store_connect.get_app(ResourceId("1481211155"))
assert isinstance(app, App)
assert app.id == "1481211155"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@priitlatt priitlatt merged commit 0bed134 into master Apr 26, 2024
11 checks passed
@priitlatt priitlatt deleted the definitions/add-missing-fields-for-models branch April 26, 2024 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants