This is an automated email from the git hooks/post-receive script.
frostyx pushed a commit to branch master
in repository copr/copr.
The following commit(s) were added to refs/heads/master by this push:
new cf4cfc3 frontend: python3-flask-script removal
cf4cfc3 is described below
commit cf4cfc348e57f7fe3d8510d255c599c0489c92f5
Author: Tomas Hrnciar <thrnciar(a)redhat.com>
AuthorDate: Tue Oct 15 09:29:37 2019 +0200
frontend: python3-flask-script removal
commands/test.py - done
Merges: #1069
---
frontend/copr-frontend.spec | 2 ++
frontend/coprs_frontend/commands/test.py | 62 +++++++++++++++-----------------
frontend/coprs_frontend/manage.py | 19 ++++++----
frontend/run_tests.sh | 2 +-
4 files changed, 44 insertions(+), 41 deletions(-)
diff --git a/frontend/copr-frontend.spec b/frontend/copr-frontend.spec
index 2a15142..55df011 100644
--- a/frontend/copr-frontend.spec
+++ b/frontend/copr-frontend.spec
@@ -69,6 +69,7 @@ BuildRequires: python3-devel
BuildRequires: fedora-messaging
BuildRequires: libmodulemd < 2
BuildRequires: libmodulemd >= 1.7.0
+BuildRequires: python3-click
BuildRequires: python3-CommonMark
BuildRequires: python3-blinker
BuildRequires: python3-copr-common > 0.4
@@ -120,6 +121,7 @@ Requires: js-jquery1
Requires: js-respond
Requires: libmodulemd < 2
Requires: libmodulemd >= 1.7.0
+Requires: python3-click
Requires: python3-CommonMark
Requires: python3-alembic
Requires: python3-blinker
diff --git a/frontend/coprs_frontend/commands/test.py
b/frontend/coprs_frontend/commands/test.py
index b2ef159..5d5fed4 100644
--- a/frontend/coprs_frontend/commands/test.py
+++ b/frontend/coprs_frontend/commands/test.py
@@ -1,37 +1,31 @@
import argparse
import os
import subprocess
-from flask_script import Command, Option
-
-
-class TestCommand(Command):
-
- def run(self, coverage, test_args):
- os.environ["COPRS_ENVIRON_UNITTEST"] = "1"
- if not (("COPR_CONFIG" in os.environ) and
os.environ["COPR_CONFIG"]):
- os.environ["COPR_CONFIG"] =
"/etc/copr/copr_unit_test.conf"
-
- if 'PYTHONPATH' in os.environ:
- os.environ['PYTHONPATH'] = os.environ['PYTHONPATH'] +
':.'
- else:
- os.environ['PYTHONPATH'] = '.'
-
- additional_args = test_args
-
- if coverage:
- additional_args.extend([
- '--cov-report', 'term-missing', '--cov',
'coprs'
- ])
-
- return subprocess.call(["/usr/bin/python3", "-m",
"pytest"] + additional_args)
-
- option_list = (
- Option("-a",
- dest="test_args",
- nargs=argparse.REMAINDER),
- Option("--coverage",
- dest="coverage",
- required=False,
- action='store_true',
- default=False),
- )
+import click
+
+(a)click.command(context_settings=dict(
+ ignore_unknown_options=True,
+))
+(a)click.argument("arguments", nargs=-1, type=click.UNPROCESSED)
+(a)click.option("--coverage/--no-coverage",
+ default=False
+)
+
+def test(coverage, arguments):
+ os.environ["COPRS_ENVIRON_UNITTEST"] = "1"
+ if not (("COPR_CONFIG" in os.environ) and
os.environ["COPR_CONFIG"]):
+ os.environ["COPR_CONFIG"] = "/etc/copr/copr_unit_test.conf"
+
+ if 'PYTHONPATH' in os.environ:
+ os.environ['PYTHONPATH'] = os.environ['PYTHONPATH'] +
':.'
+ else:
+ os.environ['PYTHONPATH'] = '.'
+
+ additional_args = list(arguments)
+
+ if coverage:
+ additional_args.extend([
+ '--cov-report', 'term-missing', '--cov',
'coprs'
+ ])
+
+ return subprocess.call(["/usr/bin/python3", "-m",
"pytest"] + additional_args)
diff --git a/frontend/coprs_frontend/manage.py b/frontend/coprs_frontend/manage.py
index add5afb..3d5841c 100755
--- a/frontend/coprs_frontend/manage.py
+++ b/frontend/coprs_frontend/manage.py
@@ -5,14 +5,14 @@ import os
import sys
import pipes
import importlib
+import click
+import commands.test
+
from flask_script import Manager
from coprs import app
-commands = {
- # General commands
- "test": "TestCommand",
-
+commands_old = {
# Database commands
"create_sqlite_file": "CreateSqliteFileCommand",
"create_db": "CreateDBCommand",
@@ -57,11 +57,18 @@ if os.getuid() == 0:
sys.exit(1)
manager = Manager(app)
-for cmdname, clsname in commands.items():
+for cmdname, clsname in commands_old.items():
module = importlib.import_module("commands.{0}".format(cmdname))
cls = getattr(module, clsname)
manager.add_command(cmdname, cls())
+app.cli.add_command(commands.test.test, "test")
if __name__ == "__main__":
- manager.run()
+ # This is just temporary while migrating to flask script,
+ # values in arrays are already migrated parameters.
+ # Else part will be removed once migration is complete.
+ if sys.argv[1] in ['test']:
+ app.cli()
+ else:
+ manager.run()
diff --git a/frontend/run_tests.sh b/frontend/run_tests.sh
index a239427..d068b84 100755
--- a/frontend/run_tests.sh
+++ b/frontend/run_tests.sh
@@ -18,4 +18,4 @@ export PYTHONPATH="${PYTHONPATH+$PYTHONPATH:}$common_path"
export COPR_CONFIG="$(pwd)/coprs_frontend/config/copr_unit_test.conf"
cd coprs_frontend
-./manage.py test -a "$@"
+./manage.py test "$@"
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.