split out options from read_config()

There is no longer any reason for these to be intertwined.

This deliberately avoids touching some files as much as possible because
they are super tangled and due to be replaced.  Those files are:

* fdroidserver/build.py
* fdroidserver/update.py

# Conflicts:
#	tests/testcommon.py

# Conflicts:
#	fdroidserver/btlog.py
#	fdroidserver/import_subcommand.py
This commit is contained in:
Hans-Christoph Steiner 2024-05-08 16:26:46 +02:00
parent 685efa23d4
commit 18f3acc32e
53 changed files with 317 additions and 265 deletions

View file

@ -24,7 +24,7 @@ import fdroidserver.common
import fdroidserver.import_subcommand
import fdroidserver.metadata
from fdroidserver.exception import FDroidException
from testcommon import TmpCwd, mkdtemp
from testcommon import TmpCwd, mkdtemp, parse_args_for_test
class ImportTest(unittest.TestCase):
@ -33,8 +33,6 @@ class ImportTest(unittest.TestCase):
def setUp(self):
logging.basicConfig(level=logging.DEBUG)
self.basedir = localmodule / 'tests'
fdroidserver.import_subcommand.options = mock.Mock()
fdroidserver.import_subcommand.options.rev = None
os.chdir(self.basedir)
self._td = mkdtemp()
self.testdir = self._td.name
@ -145,7 +143,9 @@ class ImportTest(unittest.TestCase):
fdroidserver.import_subcommand.main()
@mock.patch('sys.argv', ['fdroid import', '-u', 'https://fake/git/url.git'])
@mock.patch('fdroidserver.import_subcommand.clone_to_tmp_dir', lambda a: Path('td'))
@mock.patch(
'fdroidserver.import_subcommand.clone_to_tmp_dir', lambda a, r: Path('td')
)
def test_main_local_git(self):
os.chdir(self.testdir)
git.Repo.init('td')
@ -170,7 +170,7 @@ if __name__ == "__main__":
default=False,
help="Spew out even more information than normal",
)
fdroidserver.common.options = parser.parse_args(['--verbose'])
parse_args_for_test(parser, sys.argv)
newSuite = unittest.TestSuite()
newSuite.addTest(unittest.makeSuite(ImportTest))