mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
tests: standardize on VerboseFalseOptions as mock
This commit is contained in:
parent
7ff32bc4b0
commit
487269c667
5 changed files with 13 additions and 17 deletions
|
@ -11,16 +11,11 @@ from unittest import mock
|
||||||
import git
|
import git
|
||||||
|
|
||||||
import fdroidserver
|
import fdroidserver
|
||||||
from .testcommon import TmpCwd, mkdtemp
|
from .testcommon import TmpCwd, mkdtemp, VerboseFalseOptions
|
||||||
|
|
||||||
basedir = Path(__file__).parent
|
basedir = Path(__file__).parent
|
||||||
|
|
||||||
|
|
||||||
class Options:
|
|
||||||
quiet = False
|
|
||||||
verbose = False
|
|
||||||
|
|
||||||
|
|
||||||
class DeployTest(unittest.TestCase):
|
class DeployTest(unittest.TestCase):
|
||||||
'''fdroidserver/deploy.py'''
|
'''fdroidserver/deploy.py'''
|
||||||
|
|
||||||
|
@ -122,7 +117,7 @@ class DeployTest(unittest.TestCase):
|
||||||
fdroidserver.deploy.config['rclone'] = True
|
fdroidserver.deploy.config['rclone'] = True
|
||||||
fdroidserver.deploy.config['rclone_config'] = 'test-local-config'
|
fdroidserver.deploy.config['rclone_config'] = 'test-local-config'
|
||||||
fdroidserver.deploy.config['path_to_custom_rclone_config'] = str(rclone_file)
|
fdroidserver.deploy.config['path_to_custom_rclone_config'] = str(rclone_file)
|
||||||
fdroidserver.common.options = Options
|
fdroidserver.common.options = VerboseFalseOptions
|
||||||
|
|
||||||
# write out destination path
|
# write out destination path
|
||||||
destination = Path('test_bucket_folder/fdroid')
|
destination = Path('test_bucket_folder/fdroid')
|
||||||
|
@ -166,7 +161,7 @@ class DeployTest(unittest.TestCase):
|
||||||
fdroidserver.deploy.config['rclone'] = True
|
fdroidserver.deploy.config['rclone'] = True
|
||||||
fdroidserver.deploy.config['rclone_config'] = 'test-local-config'
|
fdroidserver.deploy.config['rclone_config'] = 'test-local-config'
|
||||||
fdroidserver.deploy.config['path_to_custom_rclone_config'] = str(rclone_file)
|
fdroidserver.deploy.config['path_to_custom_rclone_config'] = str(rclone_file)
|
||||||
fdroidserver.common.options = Options
|
fdroidserver.common.options = VerboseFalseOptions
|
||||||
|
|
||||||
# write out destination path
|
# write out destination path
|
||||||
destination = Path('test_bucket_folder/fdroid')
|
destination = Path('test_bucket_folder/fdroid')
|
||||||
|
|
|
@ -13,7 +13,7 @@ import git
|
||||||
import requests
|
import requests
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from .testcommon import TmpCwd, mkdtemp
|
from .testcommon import TmpCwd, mkdtemp, VerboseFalseOptions
|
||||||
|
|
||||||
import fdroidserver
|
import fdroidserver
|
||||||
import fdroidserver.import_subcommand
|
import fdroidserver.import_subcommand
|
||||||
|
@ -91,7 +91,7 @@ class ImportTest(unittest.TestCase):
|
||||||
print('Skipping ImportTest!')
|
print('Skipping ImportTest!')
|
||||||
return
|
return
|
||||||
|
|
||||||
fdroidserver.common.options = type('Options', (), {'verbose': False})
|
fdroidserver.common.options = VerboseFalseOptions
|
||||||
app = fdroidserver.import_subcommand.get_app_from_url(url)
|
app = fdroidserver.import_subcommand.get_app_from_url(url)
|
||||||
fdroidserver.import_subcommand.clone_to_tmp_dir(app)
|
fdroidserver.import_subcommand.clone_to_tmp_dir(app)
|
||||||
self.assertEqual(app.RepoType, 'git')
|
self.assertEqual(app.RepoType, 'git')
|
||||||
|
|
|
@ -24,7 +24,7 @@ from fdroidserver import common
|
||||||
from fdroidserver import metadata
|
from fdroidserver import metadata
|
||||||
from fdroidserver import signatures
|
from fdroidserver import signatures
|
||||||
from fdroidserver.exception import FDroidException
|
from fdroidserver.exception import FDroidException
|
||||||
from .testcommon import mkdtemp
|
from .testcommon import mkdtemp, VerboseFalseOptions
|
||||||
|
|
||||||
basedir = pathlib.Path(__file__).parent
|
basedir = pathlib.Path(__file__).parent
|
||||||
|
|
||||||
|
@ -247,12 +247,9 @@ class PublishTest(unittest.TestCase):
|
||||||
self.assertEqual(publish.config['keytool'], data['keytool'])
|
self.assertEqual(publish.config['keytool'], data['keytool'])
|
||||||
|
|
||||||
def test_sign_then_implant_signature(self):
|
def test_sign_then_implant_signature(self):
|
||||||
class Options:
|
|
||||||
verbose = False
|
|
||||||
|
|
||||||
os.chdir(self.testdir)
|
os.chdir(self.testdir)
|
||||||
|
|
||||||
common.options = Options
|
common.options = VerboseFalseOptions
|
||||||
config = common.read_config()
|
config = common.read_config()
|
||||||
if 'apksigner' not in config:
|
if 'apksigner' not in config:
|
||||||
self.skipTest('SKIPPING test_sign_then_implant_signature, apksigner not installed!')
|
self.skipTest('SKIPPING test_sign_then_implant_signature, apksigner not installed!')
|
||||||
|
|
|
@ -7,7 +7,7 @@ from git import Repo
|
||||||
|
|
||||||
import fdroidserver.common
|
import fdroidserver.common
|
||||||
import fdroidserver.metadata
|
import fdroidserver.metadata
|
||||||
from .testcommon import mkdtemp
|
from .testcommon import mkdtemp, VerboseFalseOptions
|
||||||
|
|
||||||
|
|
||||||
class VCSTest(unittest.TestCase):
|
class VCSTest(unittest.TestCase):
|
||||||
|
@ -54,7 +54,7 @@ class VCSTest(unittest.TestCase):
|
||||||
vcs, build_dir = fdroidserver.common.setup_vcs(app)
|
vcs, build_dir = fdroidserver.common.setup_vcs(app)
|
||||||
# force an init of the repo, the remote head error only occurs on the second gotorevision call
|
# force an init of the repo, the remote head error only occurs on the second gotorevision call
|
||||||
|
|
||||||
fdroidserver.common.options = type('Options', (), {'verbose': False})
|
fdroidserver.common.options = VerboseFalseOptions
|
||||||
vcs.gotorevision(build.commit)
|
vcs.gotorevision(build.commit)
|
||||||
fdroidserver.common.prepare_source(
|
fdroidserver.common.prepare_source(
|
||||||
vcs,
|
vcs,
|
||||||
|
|
|
@ -27,6 +27,10 @@ from pathlib import Path
|
||||||
GP_FINGERPRINT = 'B7C2EEFD8DAC7806AF67DFCD92EB18126BC08312A7F2D6F3862E46013C7A6135'
|
GP_FINGERPRINT = 'B7C2EEFD8DAC7806AF67DFCD92EB18126BC08312A7F2D6F3862E46013C7A6135'
|
||||||
|
|
||||||
|
|
||||||
|
class VerboseFalseOptions:
|
||||||
|
verbose = False
|
||||||
|
|
||||||
|
|
||||||
class TmpCwd:
|
class TmpCwd:
|
||||||
"""Context-manager for temporarily changing the current working directory."""
|
"""Context-manager for temporarily changing the current working directory."""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue