def test_set_beta_groups_detail() -> None: """Test that we can get a builds beta details.""" 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 build = client.build.get_from_build_number(build_number="", bundle_id=APP_ID) assert build is not None groups = [ group for group in client.beta_review.get_beta_groups(app.identifier) if group.attributes.name in ["External Testers", "Public Link Testers"] ] client.beta_review.set_beta_groups_on_build(build.identifier, groups)
def test_create_screenshot_set() -> None: """Test that we can create a screenshot set.""" 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.version.get_version(app_id=app.identifier, version_string="1.2.3") assert version is not None localizations = list( client.version.get_localizations(version_id=version.identifier)) en_us = [ localization for localization in localizations if localization.attributes.locale == "en-US" ][0] client.screenshots.create_set( localization_id=en_us.identifier, display_type=asconnect.models.ScreenshotDisplayType.app_iphone_65, )
def test_get_screenshots() -> None: """Test that we can get screenshot sets from 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.version.get_version(app_id=app.identifier, version_string="1.2.3") assert version is not None localizations = list( client.version.get_localizations(version_id=version.identifier)) assert len(localizations) > 0 en_us = [ localization for localization in localizations if localization.attributes.locale == "en-US" ][0] screenshot_set = list( client.screenshots.get_sets(localization_id=en_us.identifier))[0] screenshots = list( client.screenshots.get_screenshots( screenshot_set_id=screenshot_set.identifier)) assert len(screenshots) > 0
def test_upload_all_screenshots() -> None: """Test that we can upload all screenshots.""" 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.version.get_version(app_id=app.identifier, version_string="1.2.3") assert version is not None root_screenshots_path = "/path/to/screenshots" for localization in client.version.get_localizations( version_id=version.identifier): upload_screenshots_for_localization(localization, root_screenshots_path, client) print("Done")
def test_set_idfa() -> None: """Set the advertising ID declaration""" 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("com.microsoft.Office.Outlook") assert app is not None version = client.version.get_version(app_id=app.identifier, version_string="4.2135.0") assert version is not None client.version.set_uses_idfa(version_id=version.identifier) _ = client.version.get_idfa(version_id=version.identifier) client.version.set_idfa( version_id=version.identifier, attributes_action_with_previous_ad=True, attributes_app_installation_to_previous_ad=True, honors_limited_ad_tracking=True, serves_ads=True, )
def test_get_app() -> None: """Test that we can get an app.""" 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
def test_get_builds() -> None: """Test get apps.""" key_id, key_contents, issuer_id = get_test_data() client = asconnect.Client( key_id=key_id, key_contents=key_contents, issuer_id=issuer_id, ) builds = client.build.get_builds() assert builds is not None
def test_get_apps() -> None: """Test get apps.""" key_id, key_contents, issuer_id = get_test_data() client = asconnect.Client( key_id=key_id, key_contents=key_contents, issuer_id=issuer_id, ) apps = list(client.app.get_all()) assert len(apps) != 0 print(apps[0])
def test_get_builds_by_version() -> None: """Test get build by 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 builds = next(client.build.get_builds(app_id=app.identifier)) assert builds is not None
def test_get_users() -> None: """Test that we can upload all screenshots.""" key_id, key_contents, issuer_id = get_test_data() client = asconnect.Client( key_id=key_id, key_contents=key_contents, issuer_id=issuer_id, ) users = list(client.users.get_users()) assert len(users) > 0
def test_wait_for_build() -> None: """Test that we can wait for a build.""" 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 client.build.wait_for_build_to_process(APP_ID, "")
def test_create_new_version() -> 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 client.app.create_new_version(version="1.2.3", app_id=app.identifier)
def test_upload() -> None: """Test that we can upload a build.""" 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.build.upload( ipa_path=IPA_PATH, platform=asconnect.Platform.IOS, )
def test_beta_review_submission() -> None: """Test that we can submit a build for beta review.""" key_id, key_contents, issuer_id = get_test_data() client = asconnect.Client( key_id=key_id, key_contents=key_contents, issuer_id=issuer_id, ) build = client.build.get_from_build_number(build_number="", bundle_id=APP_ID) assert build is not None client.beta_review.submit_for_beta_review(build.identifier)
def test_get_version() -> 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, ) 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="1.2.3") assert version is not None
def test_get_build_localization_details() -> None: """Test that we can get a builds localization details.""" key_id, key_contents, issuer_id = get_test_data() client = asconnect.Client( key_id=key_id, key_contents=key_contents, issuer_id=issuer_id, ) build = client.build.get_from_build_number(build_number="", bundle_id=APP_ID) assert build is not None assert len(list(client.beta_review.get_beta_build_localizations(build.identifier))) > 0
def test_get_beta_app_localizations() -> None: """Test get beta app localizations.""" 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 client.beta_review.get_beta_app_localizations(app.identifier)
def test_get_versions() -> None: """Test that we can get app store versions.""" 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 versions = list(client.version.get_all(app_id=app.identifier)) assert len(versions) > 0
def test_get_build_beta_detail() -> None: """Test that we can get a builds beta details.""" key_id, key_contents, issuer_id = get_test_data() client = asconnect.Client( key_id=key_id, key_contents=key_contents, issuer_id=issuer_id, ) build = client.build.get_from_build_number(build_number="", bundle_id=APP_ID) assert build is not None build_detail = client.build.get_beta_detail(build) assert build_detail is not None
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 is asconnect.models.PhasedReleaseState.INACTIVE
def test_set_whats_new() -> None: """Test that we can get a builds localization details.""" key_id, key_contents, issuer_id = get_test_data() client = asconnect.Client( key_id=key_id, key_contents=key_contents, issuer_id=issuer_id, ) build = client.build.get_from_build_number(build_number="", bundle_id=APP_ID) assert build is not None client.beta_review.set_whats_new_for_build( build.identifier, {"en-US": "Bug fixes and performance improvements"}, )
def test_upload() -> None: """Test that we can upload a build.""" 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 asconnect.upload_build( ipa_path=IPA_PATH, bundle_id=APP_ID, app_id=app.identifier, username=USERNAME, password=PASSWORD, )
def test_delete_screenshot_sets() -> None: """Test that we can delete screenshot sets from 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.version.get_version(app_id=app.identifier, version_string="1.2.3") assert version is not None for localization in client.version.get_localizations(version_id=version.identifier): client.screenshots.delete_all_sets_in_localization(localization_id=localization.identifier) assert version is not None
def test_set_testflight_localized_review_details() -> None: """Test that we can set the testflight app review details.""" 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 info = { "en-US": { "feedbackEmail": "*****@*****.**", "description": "Thanks for helping us test!", } } client.beta_review.set_beta_app_localizations(app.identifier, info)
def test_set_testflight_review_details() -> None: """Test that we can set the testflight app review details.""" 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 client.beta_review.set_beta_app_review_details( app_id=app.identifier, contact_email="*****@*****.**", contact_first_name="John", contact_last_name="Doe", contact_phone="1-425-867-5309", demo_account_name="*****@*****.**", demo_account_password="******", demo_account_required=True, )
def test_get_app_info_localization() -> None: """Test that we can get app info localization.""" 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.version.get_version(app_id=app.identifier, version_string="1.2.3") assert version is not None app_infos = client.app_info.get_app_info(app_id=app.identifier) app_info = [ app_info for app_info in app_infos if app_info.attributes.app_store_state != asconnect.models.AppStoreVersionState.ready_for_sale ][0]
def test_token() -> None: """Test the JWT token generation""" key_id, key_contents, issuer_id = get_test_data() client = asconnect.Client( key_id=key_id, key_contents=key_contents, issuer_id=issuer_id, ) token = client.http_client.generate_token() decoded = jwt.decode(token, verify=False) assert decoded["iss"] == issuer_id assert decoded["aud"] == "appstoreconnect-v1" assert datetime.datetime.fromtimestamp( decoded["exp"]) < datetime.datetime.now() + datetime.timedelta( minutes=20) # Ensure we return the cached version token2 = client.http_client.generate_token() assert token == token2