mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-06-02 22:00:12 +02:00
Merge branch 'suss-refresh' into 'master'
scanner: use the refreshed data Closes #1184 See merge request fdroid/fdroidserver!1434
This commit is contained in:
commit
907dfd1c3c
|
@ -868,6 +868,8 @@ def parse_commandline():
|
|||
help=_("Don't create a source tarball, useful when testing a build"))
|
||||
parser.add_argument("--no-refresh", dest="refresh", action="store_false", default=True,
|
||||
help=_("Don't refresh the repository, useful when testing a build with no internet connection"))
|
||||
parser.add_argument("-r", "--refresh-scanner", dest="refresh_scanner", action="store_true", default=False,
|
||||
help=_("Refresh and cache scanner rules and signatures from the network"))
|
||||
parser.add_argument("-f", "--force", action="store_true", default=False,
|
||||
help=_("Force build of disabled apps, and carries on regardless of scan problems. Only allowed in test mode."))
|
||||
parser.add_argument("-a", "--all", action="store_true", default=False,
|
||||
|
|
|
@ -332,6 +332,10 @@ class ScannerTool():
|
|||
# definitions from config.yml here
|
||||
|
||||
self.scanner_data_lookup()
|
||||
|
||||
if options and options.refresh_scanner:
|
||||
self.refresh()
|
||||
|
||||
self.load()
|
||||
self.compile_regexes()
|
||||
|
||||
|
@ -784,7 +788,7 @@ def main():
|
|||
help=_("Force scan of disabled apps and builds."))
|
||||
parser.add_argument("--json", action="store_true", default=False,
|
||||
help=_("Output JSON to stdout."))
|
||||
parser.add_argument("-r", "--refresh", action="store_true", default=False,
|
||||
parser.add_argument("-r", "--refresh", dest="refresh_scanner", action="store_true", default=False,
|
||||
help=_("fetch the latest version of signatures from the web"))
|
||||
parser.add_argument("-e", "--exit-code", action="store_true", default=False,
|
||||
help=_("Exit with a non-zero code if problems were found"))
|
||||
|
@ -802,9 +806,6 @@ def main():
|
|||
# initialize/load configuration values
|
||||
common.get_config(opts=options)
|
||||
|
||||
if options.refresh:
|
||||
scanner._get_tool().refresh()
|
||||
|
||||
probcount = 0
|
||||
|
||||
appids = []
|
||||
|
|
|
@ -711,6 +711,25 @@ class Test_ScannerTool(unittest.TestCase):
|
|||
st.sdcs[0].load.assert_called_once_with()
|
||||
st.sdcs[1].load.assert_called_once_with()
|
||||
|
||||
def test_refresh_default(self):
|
||||
with mock.patch('fdroidserver.scanner.ScannerTool.refresh') as refresh:
|
||||
fdroidserver.scanner.ScannerTool()
|
||||
refresh.assert_not_called()
|
||||
|
||||
def test_refresh_true(self):
|
||||
fdroidserver.scanner.options = mock.Mock()
|
||||
fdroidserver.scanner.options.refresh_scanner = True
|
||||
with mock.patch('fdroidserver.scanner.ScannerTool.refresh') as refresh:
|
||||
fdroidserver.scanner.ScannerTool()
|
||||
refresh.assert_called_once()
|
||||
|
||||
def test_refresh_false(self):
|
||||
fdroidserver.scanner.options = mock.Mock()
|
||||
fdroidserver.scanner.options.refresh_scanner = False
|
||||
with mock.patch('fdroidserver.scanner.ScannerTool.refresh') as refresh:
|
||||
fdroidserver.scanner.ScannerTool()
|
||||
refresh.assert_not_called()
|
||||
|
||||
|
||||
class Test_main(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user