Exemple #1
0
 def test_sdkmanager(self):
     """Tests the _sdkmanager() method."""
     target_android = init_target(self.temp_dir)
     kwargs = {}
     with patch_buildozer_cmd() as m_cmd, patch_buildozer_cmd_expect(
     ) as m_cmd_expect, patch_os_isfile() as m_isfile:
         m_isfile.return_value = True
         assert m_cmd.return_value == target_android._sdkmanager(**kwargs)
     assert m_cmd.call_count == 1
     assert m_cmd_expect.call_count == 0
     assert m_isfile.call_count == 1
     kwargs = {"return_child": True}
     with patch_buildozer_cmd() as m_cmd, patch_buildozer_cmd_expect(
     ) as m_cmd_expect, patch_os_isfile() as m_isfile:
         m_isfile.return_value = True
         assert m_cmd_expect.return_value == target_android._sdkmanager(
             **kwargs)
     assert m_cmd.call_count == 0
     assert m_cmd_expect.call_count == 1
     assert m_isfile.call_count == 1
Exemple #2
0
    def test_install_platform_p4a_clone_default(self):
        """The default URL should be used for cloning p4a if no config options `p4a.url` and `p4a.fork` are set."""
        target_android = init_target(self.temp_dir)

        with patch_buildozer_cmd() as m_cmd, mock.patch(
                'buildozer.targets.android.open') as m_open:
            m_open.return_value = StringIO(
                'install_reqs = []')  # to stub setup.py parsing
            target_android._install_p4a()

        assert mock.call(
            'git clone -b master --single-branch https://github.com/kivy/python-for-android.git python-for-android',
            cwd=mock.ANY) in m_cmd.call_args_list
Exemple #3
0
    def test_install_platform_p4a_clone_url(self):
        """The `p4a.url` config should be used for cloning p4a before the `p4a.fork` option."""
        target_android = init_target(self.temp_dir, {
            'p4a.url': 'https://custom-p4a-url/p4a.git',
            'p4a.fork': 'myfork',
        })

        with patch_buildozer_cmd() as m_cmd, mock.patch(
                'buildozer.targets.android.open') as m_open:
            m_open.return_value = StringIO(
                'install_reqs = []')  # to stub setup.py parsing
            target_android._install_p4a()

        assert mock.call(
            'git clone -b master --single-branch https://custom-p4a-url/p4a.git python-for-android',
            cwd=mock.ANY) in m_cmd.call_args_list
Exemple #4
0
 def test_build_package_no_signature(self):
     """Code signing is currently required to go through final `xcodebuild` step."""
     target = init_target(self.temp_dir)
     target.ios_dir = "/ios/dir"
     # fmt: off
     with patch_target_ios("_unlock_keychain") as m_unlock_keychain, \
          patch_buildozer_error() as m_error, \
          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_load_plist_from_file.return_value = {}
         target.build_package()
     # fmt: on
     assert m_unlock_keychain.call_args_list == [mock.call()]
     assert m_error.call_args_list == [
         mock.call("Cannot create the IPA package without signature. "
                   'You must fill the "ios.codesign.debug" token.')
     ]
     assert m_load_plist_from_file.call_args_list == [
         mock.call("/ios/dir/myapp-ios/myapp-Info.plist")
     ]
     assert m_dump_plist_to_file.call_args_list == [
         mock.call(
             {
                 "CFBundleIdentifier": "org.test.myapp",
                 "CFBundleShortVersionString": "0.1",
                 "CFBundleVersion": "0.1.None",
             },
             "/ios/dir/myapp-ios/myapp-Info.plist",
         )
     ]
     assert m_cmd.call_args_list == [
         mock.call(mock.ANY, cwd=target.ios_dir),
         mock.call(
             "xcodebuild -configuration Debug -allowProvisioningUpdates ENABLE_BITCODE=NO "
             "CODE_SIGNING_ALLOWED=NO clean build",
             cwd="/ios/dir/myapp-ios",
         ),
         mock.call(
             "xcodebuild -alltargets -configuration Debug -scheme myapp "
             "-archivePath \"/ios/dir/myapp-0.1.intermediates/myapp-0.1.xcarchive\" "
             "-destination \'generic/platform=iOS\' "
             "archive ENABLE_BITCODE=NO CODE_SIGNING_ALLOWED=NO",
             cwd="/ios/dir/myapp-ios",
         ),
     ]
Exemple #5
0
 def test_unlock_keychain_wrong_password(self):
     """A `BuildozerCommandException` should be raised on wrong password 3 times."""
     target = init_target(self.temp_dir)
     # fmt: off
     with mock.patch("buildozer.targets.ios.getpass") as m_getpass, \
          patch_buildozer_cmd() as m_cmd, \
          pytest.raises(BuildozerCommandException):
         m_getpass.return_value = "password"
         # the `security unlock-keychain` command returned an error
         # hence we'll get prompted to enter the password
         m_cmd.return_value = (None, None, 123)
         target._unlock_keychain()
     # fmt: on
     assert m_getpass.call_args_list == [
         mock.call("Password to unlock the default keychain:"),
         mock.call("Password to unlock the default keychain:"),
         mock.call("Password to unlock the default keychain:"),
     ]
Exemple #6
0
 def test_install_platform(self):
     """Checks `install_platform()` calls clone commands and sets `ios_dir` and `ios_deploy_dir` attributes."""
     target = init_target(self.temp_dir)
     assert target.ios_dir is None
     assert target.ios_deploy_dir is None
     with patch_buildozer_cmd() as m_cmd:
         target.install_platform()
     assert m_cmd.call_args_list == [
         mock.call("git clone https://github.com/kivy/kivy-ios",
                   cwd=mock.ANY),
         mock.call(
             "git clone --branch 1.10.0 https://github.com/phonegap/ios-deploy",
             cwd=mock.ANY,
         ),
     ]
     assert target.ios_dir.endswith(".buildozer/ios/platform/kivy-ios")
     assert target.ios_deploy_dir.endswith(
         ".buildozer/ios/platform/ios-deploy")
Exemple #7
0
 def test_build_package_no_signature(self):
     """Code signing is currently required to go through final `xcodebuild` steps."""
     target = init_target(self.temp_dir)
     target.ios_dir = "/ios/dir"
     # fmt: off
     with patch_target_ios("_unlock_keychain") as m_unlock_keychain, \
          patch_buildozer_error() as m_error, \
          patch_target_ios("xcodebuild") as m_xcodebuild, \
          mock.patch("buildozer.targets.ios.plistlib.readPlist") as m_readplist, \
          mock.patch("buildozer.targets.ios.plistlib.writePlist") as m_writeplist, \
          patch_buildozer_cmd() as m_cmd:
         m_readplist.return_value = {}
         target.build_package()
     # fmt: on
     assert m_unlock_keychain.call_args_list == [mock.call()]
     assert m_error.call_args_list == [
         mock.call("Cannot create the IPA package without signature. "
                   'You must fill the "ios.codesign.debug" token.')
     ]
     assert m_xcodebuild.call_args_list == [
         mock.call(
             "-configuration Debug ENABLE_BITCODE=NO "
             "CODE_SIGNING_ALLOWED=NO clean build",
             cwd="/ios/dir/myapp-ios",
         )
     ]
     assert m_readplist.call_args_list == [
         mock.call("/ios/dir/myapp-ios/myapp-Info.plist")
     ]
     assert m_writeplist.call_args_list == [
         mock.call(
             {
                 "CFBundleIdentifier": "org.test.myapp",
                 "CFBundleShortVersionString": "0.1",
                 "CFBundleVersion": "0.1.None",
             },
             "/ios/dir/myapp-ios/myapp-Info.plist",
         )
     ]
     assert m_cmd.call_args_list == [
         mock.call(mock.ANY, cwd=target.ios_dir)
     ]