#328 Fix tests and relative issues to tests
Merged by jkaluza. Opened by cqi.
cqi/freshmaker fix-tests  into  master

Download 328.patch
no initial comment

Pretty please pagure-ci rebuild

:+1: Looks great! This fixes py35 and flake8 for me.

I don't think the Jenkins job is working properly for freshmaker. Last run was on Oct 12, 2018.

Also, looking at the Jenkinsfile, only flake8 runs. The unit tests are not executed. We should fix that too, but I'm assuming this is probably a bigger task. Let's do it on a different PR.

Unit tests for py27 are still broken on my env. I had to create a symlink to even get the tests started:

$ sudo ln -s $PWD/conf/configrh.py /etc/freshmaker/config.py

But then it fails due to prometheus_client import error: ImportError: No module named prometheus_client

This is probably because we're using system site packages.
If we stop using system site packages, it fails in py27 with ImportError for queue module this time. This is because the module is Queue in python 2. So... let's use six.moves to fix this particular problem. This patch on top of this PR did it for me:

diff --git a/tests/test_monitor.py b/tests/test_monitor.py
index 046c108..5ed025d 100644
--- a/tests/test_monitor.py
+++ b/tests/test_monitor.py
@@ -22,9 +22,9 @@
 import fedmsg.config
 import mock
 import freshmaker
-import queue
 from freshmaker import app, db, events, models, login_manager
+from six.moves import queue
 from tests import helpers
diff --git a/tests/test_odcsclient.py b/tests/test_odcsclient.py
index eb89982..49fdaf3 100644
--- a/tests/test_odcsclient.py
+++ b/tests/test_odcsclient.py
@@ -24,10 +24,10 @@
 import fedmsg
 import six
-import queue
 from mock import patch, Mock, MagicMock
 from odcs.client.odcs import AuthMech
+from six.moves import queue
 from freshmaker import conf, db
 from freshmaker.models import Event, ArtifactBuild, Compose
diff --git a/tests/test_producer.py b/tests/test_producer.py
index 4e2d1f7..af462bc 100644
--- a/tests/test_producer.py
+++ b/tests/test_producer.py
@@ -23,9 +23,9 @@
 # Written by Jan Kaluza <jkaluza@redhat.com>
 from mock import patch, MagicMock
+from six.moves import queue
 import koji
 import fedmsg.config
-import queue
 import freshmaker
 from freshmaker import db
diff --git a/tox.ini b/tox.ini
index 9c83f0e..9943d8a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -7,7 +7,6 @@
 envlist = py27, py35, coverage, flake8, bandit
 [testenv]
-sitepackages=True
 skip_install = True
 deps = -r{toxinidir}/test-requirements.txt
 commands =

3 new commits added

  • Remove krbcontext from requirements.txt
  • Adjust tox to run coverage
  • sitepackages is not necessary to run tests

@lucarval

Unit tests for py27 are still broken on my env. I had to create a symlink to even get the tests started:
$ sudo ln -s $PWD/conf/configrh.py /etc/freshmaker/config.py

I don't see this issue in my system. My steps to run tox are:

python3 -m venv .env
. .env/bin/activate
pip install -r test-requirements.txt
tox

New commits are added. sitepackages is not necessary to run tests and is disabled. I also refactored testenv for coverage.

I think @lucarval did not run the tox, but nosetests maybe? Not sure though.

Tests are passing for me locally, merging.

Commit be5689e2 fixes this pull-request

Pull-Request has been merged by jkaluza

Pull-Request has been merged by jkaluza

Metadata