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

Fix CI tests for iOS and Android #1365

Merged
merged 3 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def __init__(self, *args, **kwargs):
else:
self.extra_p4a_args += ' --ignore-setup-py'


activity_class_name = self.buildozer.config.getdefault(
'app', 'android.activity_class_name', 'org.kivy.android.PythonActivity')
if activity_class_name != 'org.kivy.android.PythonActivity':
Expand Down
14 changes: 10 additions & 4 deletions buildozer/targets/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ def get_available_packages(self):
available_modules = self.toolchain("recipes --compact", get_stdout=True)[0]
return available_modules.splitlines()[0].split()

def load_plist_from_file(self, plist_rfn):
with open(plist_rfn, 'rb') as f:
return plistlib.load(f)

def dump_plist_to_file(self, plist, plist_rfn):
with open(plist_rfn, 'wb') as f:
plistlib.dump(plist, f)

def compile_platform(self):
# for ios, the compilation depends really on the app requirements.
# compile the distribution only if the requirements changed.
Expand Down Expand Up @@ -207,8 +215,7 @@ def build_package(self):
plist_rfn = join(self.app_project_dir, plist_fn)
version = self.buildozer.get_version()
self.buildozer.info('Update Plist {}'.format(plist_fn))
with open(plist_rfn, 'rb') as f:
plist = plistlib.load(f)
plist = self.load_plist_from_file(plist_rfn)
plist['CFBundleIdentifier'] = self._get_package()
plist['CFBundleShortVersionString'] = version
plist['CFBundleVersion'] = '{}.{}'.format(version,
Expand Down Expand Up @@ -236,8 +243,7 @@ def build_package(self):
}

# ok, write the modified plist.
with open(plist_rfn, 'wb') as f:
plistlib.dump(plist, f)
self.dump_plist_to_file(plist, plist_rfn)

mode = self.build_mode.capitalize()
self.xcodebuild(
Expand Down
2 changes: 1 addition & 1 deletion tests/targets/test_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_init(self):
assert (
target_android.extra_p4a_args == (
' --color=always'
' --storage-dir="{buildozer_dir}/android/platform/build-armeabi-v7a" --ndk-api=21 --ignore-setup-py'.format(
' --storage-dir="{buildozer_dir}/android/platform/build-armeabi-v7a" --ndk-api=21 --ignore-setup-py --debug'.format(
buildozer_dir=buildozer.buildozer_dir)
)
)
Expand Down
10 changes: 5 additions & 5 deletions tests/targets/test_ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ def test_build_package_no_signature(self):
# fmt: off
with patch_target_ios("_unlock_keychain") as m_unlock_keychain, \
patch_buildozer_error() as m_error, \
mock.patch("buildozer.targets.ios.plistlib.readPlist") as m_readplist, \
mock.patch("buildozer.targets.ios.plistlib.writePlist") as m_writeplist, \
mock.patch("buildozer.targets.ios.TargetIos.load_plist_from_file") as m_load_plist_from_file, \
mock.patch("buildozer.targets.ios.TargetIos.dump_plist_to_file") as m_dump_plist_to_file, \
patch_buildozer_cmd() as m_cmd:
m_readplist.return_value = {}
m_load_plist_from_file.return_value = {}
target.build_package()
# fmt: on
assert m_unlock_keychain.call_args_list == [mock.call()]
Expand All @@ -195,10 +195,10 @@ def test_build_package_no_signature(self):
'You must fill the "ios.codesign.debug" token.'
)
]
assert m_readplist.call_args_list == [
assert m_load_plist_from_file.call_args_list == [
mock.call("/ios/dir/myapp-ios/myapp-Info.plist")
]
assert m_writeplist.call_args_list == [
assert m_dump_plist_to_file.call_args_list == [
mock.call(
{
"CFBundleIdentifier": "org.test.myapp",
Expand Down