From 23280b6029055a028059eda76863ab6cd4af2787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=B6hn?= Date: Tue, 23 Jul 2019 20:45:04 +0200 Subject: [PATCH] checkupdates add check_http test --- tests/checkupdates.TestCase | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/checkupdates.TestCase b/tests/checkupdates.TestCase index d6231f62..e310fc8f 100755 --- a/tests/checkupdates.TestCase +++ b/tests/checkupdates.TestCase @@ -53,6 +53,23 @@ class CommonTest(unittest.TestCase): fdroidserver.checkupdates.checkupdates_app(app) wrmock.assert_called_with(app.metadatapath, app) + def test_check_http(self): + fdroidserver.checkupdates.options = mock.Mock() + + app = fdroidserver.metadata.App() + app.id = 'loop.starts.shooting' + app.metadatapath = 'metadata/' + app.id + '.yml' + app.CurrentVersionCode = 10108 + app.UpdateCheckMode = 'HTTP' + app.UpdateCheckData = 'https://a.net/b.txt|c(.*)|https://d.net/e.txt|v(.*)' + + respmock = mock.Mock() + respmock.read = lambda: 'v1.1.9\nc10109'.encode('utf-8') + with mock.patch('urllib.request.urlopen', lambda a, b, c: respmock): + vername, vercode = fdroidserver.checkupdates.check_http(app) + self.assertEqual(vername, '1.1.9') + self.assertEqual(vercode, '10109') + if __name__ == "__main__": os.chdir(os.path.dirname(__file__))