From 450765490b8f21cb8d0050052539741aa87c3575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=B6hn?= Date: Thu, 4 Apr 2024 13:04:55 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=BA=EF=B8=8F=20=20add=20test=20for=20?= =?UTF-8?q?=5Fget=5Fipa=5Fico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/update.TestCase | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/update.TestCase b/tests/update.TestCase index 81036cd6..0ce7a85c 100755 --- a/tests/update.TestCase +++ b/tests/update.TestCase @@ -2201,6 +2201,33 @@ class TestCopyIosScreenshotsToRepo(unittest.TestCase): ) +class TestGetIpaIcon(unittest.TestCase): + def test_get_ipa_icon(self): + self.maxDiff = None + + with tempfile.TemporaryDirectory() as tmpdir: + tmpdir = Path(tmpdir) + (tmpdir / 'OnionBrowser.xcodeproj').mkdir() + with open(tmpdir / 'OnionBrowser.xcodeproj/project.pbxproj', "w") as f: + f.write("") + icondir = tmpdir / "fake_icon.appiconset" + icondir.mkdir() + with open(icondir / "Contents.json", "w", encoding="utf-8") as f: + f.write(""" + {"images": [ + {"scale": "2x", "size": "128x128", "filename": "nope"}, + {"scale": "1x", "size": "512x512", "filename": "nope"}, + {"scale": "1x", "size": "16x16", "filename": "nope"}, + {"scale": "1x", "size": "32x32", "filename": "yep"} + ]} + """) + + pfp = mock.Mock(return_value="fake_icon") + with(mock.patch("fdroidserver.update._parse_from_pbxproj", pfp)): + p = fdroidserver.update._get_ipa_icon(tmpdir) + self.assertEqual(str(icondir / "yep"), p) + + if __name__ == "__main__": os.chdir(os.path.dirname(__file__)) @@ -2221,4 +2248,5 @@ if __name__ == "__main__": newSuite.addTest(unittest.makeSuite(TestParseIosScreenShotName)) newSuite.addTest(unittest.makeSuite(TestInsertLocalizedIosAppMetadata)) newSuite.addTest(unittest.makeSuite(TestDiscoverIosScreenshots)) + newSuite.addTest(unittest.makeSuite(TestGetIpaIcon)) unittest.main(failfast=False)