1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-01 08:40:11 +02:00

fix IndexTest.test_gitlab_get_mirror_service_urls

This makes it actually call the method rather than mocking it.
This commit is contained in:
Hans-Christoph Steiner 2021-09-13 13:18:21 +02:00
parent 0783f97bed
commit 8ea154c125

View File

@ -27,6 +27,7 @@ import fdroidserver.net
import fdroidserver.signindex import fdroidserver.signindex
import fdroidserver.publish import fdroidserver.publish
from testcommon import TmpCwd from testcommon import TmpCwd
from pathlib import Path
GP_FINGERPRINT = 'B7C2EEFD8DAC7806AF67DFCD92EB18126BC08312A7F2D6F3862E46013C7A6135' GP_FINGERPRINT = 'B7C2EEFD8DAC7806AF67DFCD92EB18126BC08312A7F2D6F3862E46013C7A6135'
@ -371,27 +372,31 @@ class IndexTest(unittest.TestCase):
) )
def test_gitlab_get_mirror_service_urls(self): def test_gitlab_get_mirror_service_urls(self):
for url in [ with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
'git@gitlab.com:group/project', os.mkdir('fdroid')
'git@gitlab.com:group/project.git', with Path('fdroid/placeholder').open('w') as fp:
'https://gitlab.com/group/project', fp.write(' ')
'https://gitlab.com/group/project.git', for url in [
]: 'git@gitlab.com:group/project',
with patch('fdroidserver.common.get_dir_size', return_value=100000): 'git@gitlab.com:group/project.git',
self.assertEqual( 'https://gitlab.com/group/project',
[ 'https://gitlab.com/group/project.git',
'https://group.gitlab.io/project/fdroid', ]:
'https://gitlab.com/group/project/-/raw/master/fdroid', with patch('fdroidserver.common.GITLAB_COM_PAGES_MAX_SIZE', 1000):
], self.assertEqual(
fdroidserver.index.get_mirror_service_urls(url), [
) 'https://group.gitlab.io/project/fdroid',
with patch('fdroidserver.common.get_dir_size', return_value=1234567890): 'https://gitlab.com/group/project/-/raw/master/fdroid',
self.assertEqual( ],
[ fdroidserver.index.get_mirror_service_urls(url),
'https://gitlab.com/group/project/-/raw/master/fdroid', )
], with patch('fdroidserver.common.GITLAB_COM_PAGES_MAX_SIZE', 10):
fdroidserver.index.get_mirror_service_urls(url), self.assertEqual(
) [
'https://gitlab.com/group/project/-/raw/master/fdroid',
],
fdroidserver.index.get_mirror_service_urls(url),
)
def test_make_website(self): def test_make_website(self):
tmptestsdir = tempfile.mkdtemp( tmptestsdir = tempfile.mkdtemp(