Skip to content

Commit e3a7955

Browse files
vinzenzpirat89
authored andcommitted
tests: Add ability to test commands
Adding now commands/ to the test search places. Additionally fixed the problems within commands found by pylint. Signed-off-by: Vinzenz Feenstra <[email protected]>
1 parent eab3cf3 commit e3a7955

File tree

8 files changed

+23
-9
lines changed

8 files changed

+23
-9
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ space +=
1616
comma := ,
1717
REPOSITORIES ?= $(shell ls repos/system_upgrade/ | xargs echo | tr ' ' ',')
1818
SYSUPG_TEST_PATHS=repos/system_upgrade/$(subst $(comma),$(space)repos/system_upgrade/,$(REPOSITORIES))
19-
TEST_PATHS:=repos/common
19+
TEST_PATHS:=commands repos/common
2020
TEST_PATHS += ${SYSUPG_TEST_PATHS}
2121

2222

@@ -215,14 +215,14 @@ install-deps:
215215
. $(VENVNAME)/bin/activate; \
216216
pip install -U pip; \
217217
pip install --upgrade setuptools; \
218-
pip install --upgrade -r requirements.txt \
218+
pip install --upgrade -r requirements.txt; \
219+
./utils/install_commands.sh $(_PYTHON_VENV); \
219220
# In case the top commit Depends-On some yet unmerged framework patch - override master leapp with the proper version
220221
if [[ ! -z "$(REQ_LEAPP_PR)" ]] ; then \
221222
echo "Leapp-repository depends on the yet unmerged pr of the framework #$(REQ_LEAPP_PR), installing it.." && \
222223
$(VENVNAME)/bin/pip install -I "git+https://github.com/oamg/leapp.git@refs/pull/$(REQ_LEAPP_PR)/head"; \
223224
fi
224225
$(_PYTHON_VENV) utils/install_actor_deps.py --actor=$(ACTOR) --repos="$(TEST_PATHS)"
225-
226226
install-deps-fedora:
227227
@# Check the necessary rpms are installed for py3 (and py2 below)
228228
if ! rpm -q git findutils python3-virtualenv gcc; then \
@@ -238,6 +238,7 @@ install-deps-fedora:
238238
pip install -U pip; \
239239
pip install --upgrade setuptools; \
240240
pip install --upgrade -r requirements.txt; \
241+
./utils/install_commands.sh $(_PYTHON_VENV); \
241242
# In case the top commit Depends-On some yet unmerged framework patch - override master leapp with the proper version
242243
if [[ ! -z "$(REQ_LEAPP_PR)" ]] ; then \
243244
echo "Leapp-repository depends on the yet unmerged pr of the framework #$(REQ_LEAPP_PR), installing it.." && \

commands/rerun/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def rerun(args):
6060
db.execute('''DELETE FROM message WHERE context = ? and type = 'ErrorModel';''', (context,))
6161

6262
util.archive_logfiles()
63-
upgrade(Namespace(
63+
upgrade(Namespace( # pylint: disable=no-value-for-parameter
6464
resume=True,
6565
resume_context=context,
6666
only_with_tags=args.only_actors_with_tag or [],

commands/tests/.gitkeep

Whitespace-only changes.

commands/upgrade/breadcrumbs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
from leapp.utils.audit import get_messages
1010

1111
try:
12-
from json.decoder import JSONDecodeError
12+
from json.decoder import JSONDecodeError # pylint: disable=ungrouped-imports
1313
except ImportError:
1414
JSONDecodeError = ValueError
1515

1616

17-
class _BreadCrumbs:
17+
class _BreadCrumbs(object):
1818
def __init__(self, activity):
1919
self._crumbs = {
2020
'activity': activity,
@@ -76,7 +76,7 @@ def produces_breadcrumbs(f):
7676
"""
7777
Ensures that `/etc/migration-results` gets produced on every invocation of `leapp upgrade` & `leapp preupgrade`
7878
79-
Every execution of the upgrade will have their own entry in the /etc/migration-results file.
79+
Every execution of the upgrade will have their own entry in the /etc/migration-results file.
8080
For a user flow like: leapp preupgrade && leapp upgrade && reboot there should be 5 new entries in the file:
8181
8282
1. leapp preupgrade

conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def _load_and_add_repo(manager, repo_path):
3434
def pytest_collectstart(collector):
3535
if collector.nodeid:
3636
current_repo_basedir = find_repository_basedir(str(collector.fspath))
37+
if not current_repo_basedir:
38+
# This is not a repository
39+
return
3740
if not hasattr(collector.session, "leapp_repository"):
3841
collector.session.leapp_repository = RepositoryManager()
3942
collector.session.repo_base_dir = current_repo_basedir

packaging/leapp-repository.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ install -m 0644 etc/leapp/transaction/* %{buildroot}%{_sysconfdir}/leapp/transac
186186
# install CLI commands for the leapp utility on the expected path
187187
install -m 0755 -d %{buildroot}%{leapp_python_sitelib}/leapp/cli/
188188
cp -r commands %{buildroot}%{leapp_python_sitelib}/leapp/cli/
189+
rm -rf %{buildroot}%{leapp_python_sitelib}/leapp/cli/commands/tests
189190

190191
# Remove irrelevant repositories - We don't want to ship them for the particular
191192
# RHEL version

utils/container-tests/Containerfile.ubi7

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ RUN yum update -y && \
1818
# module of pip version 20.3.0 and then make it update to 20.3.4 resulting the 'pip' command to be available.
1919
# The --target approach doesn't add it, but at least we now have pip 20.3.4 installed ;-)
2020
RUN yum -y install python27-python-pip && \
21-
scl enable python27 -- pip install -U --target /usr/lib/python2.7/site-packages/ pip==20.3.0 virtualenv && \
22-
python -m pip install --ignore-installed pip==20.3.4 ipaddress
21+
scl enable python27 -- pip install -U --target /usr/lib/python2.7/site-packages/ pip==20.3.0 && \
22+
python -m pip install --ignore-installed pip==20.3.4 ipaddress virtualenv
2323

2424
WORKDIR /payload
2525
ENTRYPOINT make install-deps && make test

utils/install_commands.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
LEAPP_CLI_COMMANDS_PATH=$($1 -c "import leapp.cli.commands; print(leapp.cli.commands.__path__[0])")
4+
echo "Installing commands to \"$LEAPP_CLI_COMMANDS_PATH\""
5+
for folder in `ls -1 commands/`; do
6+
if [[ $folder != "tests" ]]; then
7+
cp -a commands/$folder $LEAPP_CLI_COMMANDS_PATH;
8+
fi
9+
done

0 commit comments

Comments
 (0)