def test_private_key_invalid_path(namespace_kwargs): os.environ[Types.PrivateKeyArgument.environment_variable_key] = '@file:this-is-not-a-file' namespace_kwargs[AppStoreConnectArgument.PRIVATE_KEY.key] = None cli_args = argparse.Namespace(**{k: v for k, v in namespace_kwargs.items()}) with pytest.raises(argparse.ArgumentTypeError) as exception_info: AppStoreConnect.from_cli_args(cli_args) assert 'this-is-not-a-file' in str(exception_info.value)
def _test_missing_argument(argument, _namespace_kwargs): cli_args = argparse.Namespace(**{k: v for k, v in _namespace_kwargs.items()}) with pytest.raises(argparse.ArgumentError) as exception_info: AppStoreConnect.from_cli_args(cli_args) message = str(exception_info.value) assert argument.key.upper() in message assert argument.type.environment_variable_key in message assert ','.join(argument.flags) in message
def _do_private_key_assertions(private_key_value, moc_appstore_api_client, cli_namespace): cli_args = argparse.Namespace(**cli_namespace) _ = AppStoreConnect.from_cli_args(cli_args).api_client _, _, private_key_arg = moc_appstore_api_client.call_args[0] assert isinstance(private_key_arg, str) assert private_key_arg == private_key_value
def _do_private_key_assertions(private_key_value, moc_api_client, cli_namespace): cli_args = argparse.Namespace(**{k: v for k, v in cli_namespace.items()}) _ = AppStoreConnect.from_cli_args(cli_args) _, _, private_key_arg = moc_api_client.call_args[0] assert isinstance(private_key_arg, str) assert private_key_arg == private_key_value
def test_publish_action_without_app_store_connect_key(namespace_kwargs): namespace_kwargs.update({ AppStoreConnectArgument.ISSUER_ID.key: None, AppStoreConnectArgument.KEY_IDENTIFIER.key: None, AppStoreConnectArgument.PRIVATE_KEY.key: None, 'action': 'publish', }) cli_args = argparse.Namespace(**namespace_kwargs) _ = AppStoreConnect.from_cli_args(cli_args)
def test_publish_action_without_app_store_connect_key_testflight_submit( missing_argument, namespace_kwargs): namespace_kwargs.update({missing_argument.key: None, 'action': 'publish'}) cli_args = argparse.Namespace(**namespace_kwargs) app_store_connect = AppStoreConnect.from_cli_args(cli_args) with pytest.raises(argparse.ArgumentError) as error_info: app_store_connect.publish( application_package_path_patterns=[pathlib.Path('path.pattern')], submit_to_testflight=True, ) assert missing_argument.flag in error_info.value.argument_name
def test_missing_arg_from_env(mock_appstore_api_client, namespace_kwargs, argument, api_client_arg_index): namespace_kwargs[argument.key] = None cli_args = argparse.Namespace(**{k: v for k, v in namespace_kwargs.items()}) os.environ[argument.value.type.environment_variable_key] = 'environment-value' _ = AppStoreConnect.from_cli_args(cli_args) api_client_args = mock_appstore_api_client.call_args[0] client_arg = api_client_args[api_client_arg_index] assert isinstance(client_arg, argument.type.argument_type) assert client_arg == argument.type.argument_type('environment-value')
def test_publish_action_with_username_and_password(_mock_altool, namespace_kwargs): namespace_kwargs.update({ AppStoreConnectArgument.ISSUER_ID.key: None, AppStoreConnectArgument.KEY_IDENTIFIER.key: None, AppStoreConnectArgument.PRIVATE_KEY.key: None, 'action': 'publish', }) cli_args = argparse.Namespace(**namespace_kwargs) with mock.patch.object(AppStoreConnect, 'find_paths') as mock_find_paths, \ mock.patch.object(AppStoreConnect, '_get_publishing_application_packages') as mock_get_packages: mock_get_packages.return_value = [] mock_find_paths.return_value = [] patterns = [pathlib.Path('path.pattern')] AppStoreConnect.from_cli_args(cli_args).publish( application_package_path_patterns=patterns, apple_id='*****@*****.**', app_specific_password=Types.AppSpecificPassword( 'xxxx-yyyy-zzzz-wwww'), ) mock_get_packages.assert_called_with(patterns)