1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-21 04:10:37 +02:00

test(deploy): make sure the APK file is not uploaded in the index only mode

This commit is contained in:
proletarius101 2024-06-02 23:27:58 +08:00
parent 04987a021b
commit 4941e699df
No known key found for this signature in database

View File

@ -925,8 +925,9 @@ class DeployTest(unittest.TestCase):
os.chdir(self.testdir)
repo = Path('repo')
repo.mkdir(parents=True)
files_in_repo = fdroidserver.deploy.INDEX_FILES + ['Sym.apk']
for filename in files_in_repo:
fake_apk = 'Sym.apk'
fake_files = fdroidserver.deploy.INDEX_FILES + [fake_apk]
for filename in fake_files:
fake_file = repo / filename
with fake_file.open('w') as fp:
fp.write('not a real one, but has the right filename')
@ -939,7 +940,7 @@ class DeployTest(unittest.TestCase):
Path(self.testdir) / 'verify',
)
for filename in files_in_repo:
for filename in fake_files:
remote_file = f"fdroid/{repo_section}/{filename}"
self.assertIsNotNone(verify_repo.working_tree_dir)
@ -977,8 +978,9 @@ class DeployTest(unittest.TestCase):
os.chdir(self.testdir)
repo = Path('repo')
repo.mkdir(parents=True)
files_in_repo = fdroidserver.deploy.INDEX_FILES
for filename in files_in_repo:
fake_apk = 'Sym.apk'
fake_files = fdroidserver.deploy.INDEX_FILES + [fake_apk]
for filename in fake_files:
fake_file = repo / filename
with fake_file.open('w') as fp:
fp.write('not a real one, but has the right filename')
@ -991,7 +993,7 @@ class DeployTest(unittest.TestCase):
Path(self.testdir) / 'verify',
)
for filename in files_in_repo:
for filename in fdroidserver.deploy.INDEX_FILES:
remote_file = f"fdroid/{repo_section}/{filename}"
self.assertIsNotNone(verify_repo.working_tree_dir)
@ -1000,6 +1002,13 @@ class DeployTest(unittest.TestCase):
(Path(verify_repo.working_tree_dir) / remote_file).exists()
)
# Should not have the APK file
remote_file = f"fdroid/{repo_section}/{fake_apk}"
if verify_repo.working_tree_dir is not None:
self.assertFalse(
(Path(verify_repo.working_tree_dir) / remote_file).exists()
)
def test_upload_to_servergitmirror_in_index_only_mode(self):
# setup parameters for this test run
fdroidserver.deploy.options = mock.Mock()
@ -1026,7 +1035,9 @@ class DeployTest(unittest.TestCase):
fdroid_dir = local_git_repo_path / 'fdroid'
repo_dir = fdroid_dir / repo_section
repo_dir.mkdir(parents=True)
for filename in fdroidserver.deploy.INDEX_FILES:
fake_apk = 'Sym.apk'
fake_files = fdroidserver.deploy.INDEX_FILES + [fake_apk]
for filename in fake_files:
fake_file = repo_dir / filename
with fake_file.open('w') as fp:
fp.write('not a real one, but has the right filename')
@ -1064,6 +1075,13 @@ class DeployTest(unittest.TestCase):
(Path(verify_repo.working_tree_dir) / remote_file).exists()
)
# Should not have the APK file
remote_file = f"fdroid/{repo_section}/{fake_apk}"
if verify_repo.working_tree_dir is not None:
self.assertFalse(
(Path(verify_repo.working_tree_dir) / remote_file).exists()
)
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))