From cef42e2541f7ddeaf284b1350eed7f4e46234fe9 Mon Sep 17 00:00:00 2001
From: Jason DeTiberus <jdetiber@redhat.com>
Date: Mon, 28 Nov 2016 15:32:46 -0500
Subject: update tests and flake8/pylint fixes

---
 utils/Makefile               | 29 ++++++++---------------------
 utils/setup.cfg              | 13 +++++++++++++
 utils/setup.py               |  2 +-
 utils/src/ooinstall/utils.py |  3 +++
 utils/test-requirements.txt  |  2 +-
 5 files changed, 26 insertions(+), 23 deletions(-)

(limited to 'utils')

diff --git a/utils/Makefile b/utils/Makefile
index 62f08f74b..ee6b885e6 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -31,8 +31,6 @@ ASCII2MAN = a2x -D $(dir $@) -d manpage -f manpage $<
 MANPAGES := docs/man/man1/atomic-openshift-installer.1
 VERSION := 1.3
 
-PEPEXCLUDES := E501,E121,E124
-
 sdist: clean
 	python setup.py sdist
 	rm -fR $(SHORTNAME).egg-info
@@ -66,7 +64,7 @@ virtualenv:
 	@echo "# Creating a virtualenv"
 	@echo "#############################################"
 	virtualenv $(NAME)env
-	 . $(NAME)env/bin/activate && pip install setuptools==17.1.1
+	. $(NAME)env/bin/activate && pip install setuptools==17.1.1
 	. $(NAME)env/bin/activate && pip install -r test-requirements.txt
 #       If there are any special things to install do it here
 #       . $(NAME)env/bin/activate && INSTALL STUFF
@@ -75,14 +73,14 @@ ci-unittests:
 	@echo "#############################################"
 	@echo "# Running Unit Tests in virtualenv"
 	@echo "#############################################"
-	. $(NAME)env/bin/activate && nosetests -v --with-coverage --cover-html --cover-min-percentage=70 --cover-package=$(SHORTNAME) test/
+	. $(NAME)env/bin/activate && python setup.py nosetests
 	@echo "VIEW CODE COVERAGE REPORT WITH 'xdg-open cover/index.html' or run 'make viewcover'"
 
 ci-pylint:
 	@echo "#############################################"
 	@echo "# Running PyLint Tests in virtualenv"
 	@echo "#############################################"
-	. $(NAME)env/bin/activate && python -m pylint --rcfile ../git/.pylintrc src/ooinstall/cli_installer.py src/ooinstall/oo_config.py src/ooinstall/openshift_ansible.py src/ooinstall/variants.py ../callback_plugins/openshift_quick_installer.py ../roles/openshift_certificate_expiry/library/openshift_cert_expiry.py
+	. $(NAME)env/bin/activate && python -m pylint --rcfile ../git/.pylintrc $(shell find ../ -name $(NAME)env -prune -o -name test -prune -o -name "*.py" -print)
 
 ci-list-deps:
 	@echo "#############################################"
@@ -90,23 +88,12 @@ ci-list-deps:
 	@echo "#############################################"
 	. $(NAME)env/bin/activate && pip freeze
 
-ci-pyflakes:
-	@echo "#################################################"
-	@echo "# Running Pyflakes Compliance Tests in virtualenv"
-	@echo "#################################################"
-	. $(NAME)env/bin/activate && pyflakes src/ooinstall/*.py
-	. $(NAME)env/bin/activate && pyflakes ../callback_plugins/openshift_quick_installer.py
-	. $(NAME)env/bin/activate && pyflakes ../roles/openshift_certificate_expiry/library/openshift_cert_expiry.py
-
-ci-pep8:
+ci-flake8:
 	@echo "#############################################"
-	@echo "# Running PEP8 Compliance Tests in virtualenv"
+	@echo "# Running Flake8 Compliance Tests in virtualenv"
 	@echo "#############################################"
-	. $(NAME)env/bin/activate && pep8 --ignore=$(PEPEXCLUDES) src/$(SHORTNAME)/
-	. $(NAME)env/bin/activate && pep8 --ignore=$(PEPEXCLUDES) ../callback_plugins/openshift_quick_installer.py
-# This one excludes E402 because it is an ansible module and the
-# boilerplate import statement is expected to be at the bottom
-	. $(NAME)env/bin/activate && pep8 --ignore=$(PEPEXCLUDES),E402 ../roles/openshift_certificate_expiry/library/openshift_cert_expiry.py
+	. $(NAME)env/bin/activate && flake8 --config=setup.cfg ../ --exclude="utils,../inventory"
+	. $(NAME)env/bin/activate && python setup.py flake8 
 
-ci: clean virtualenv ci-list-deps ci-pep8 ci-pylint ci-pyflakes ci-unittests
+ci: clean virtualenv ci-list-deps ci-flake8 ci-pylint ci-unittests
 	:
diff --git a/utils/setup.cfg b/utils/setup.cfg
index 79bc67848..f5f0d8aad 100644
--- a/utils/setup.cfg
+++ b/utils/setup.cfg
@@ -3,3 +3,16 @@
 # 3. If at all possible, it is good practice to do this. If you cannot, you
 # will need to generate wheels for each Python version that you support.
 universal=1
+
+[nosetests]
+tests=../,../roles/openshift_master_facts/test/,test/
+verbosity=2
+with_coverage=1
+cover_html=1
+cover_package=ooinstall
+cover_min_percentage=70
+
+[flake8]
+max-line-length=120
+exclude=tests/*,setup.py
+ignore=E501,E121,E124
diff --git a/utils/setup.py b/utils/setup.py
index 7909321c9..3518581e7 100644
--- a/utils/setup.py
+++ b/utils/setup.py
@@ -47,7 +47,7 @@ setup(
     # your project is installed. For an analysis of "install_requires" vs pip's
     # requirements files see:
     # https://packaging.python.org/en/latest/requirements.html
-    install_requires=['click', 'PyYAML'],
+    install_requires=['click', 'PyYAML', 'ansible'],
 
     # List additional groups of dependencies here (e.g. development
     # dependencies). You can install these using the following syntax,
diff --git a/utils/src/ooinstall/utils.py b/utils/src/ooinstall/utils.py
index 85a77c75e..c9e3e25e5 100644
--- a/utils/src/ooinstall/utils.py
+++ b/utils/src/ooinstall/utils.py
@@ -1,3 +1,5 @@
+# pylint: disable=missing-docstring,invalid-name
+
 import logging
 import re
 
@@ -8,6 +10,7 @@ installer_log = logging.getLogger('installer')
 def debug_env(env):
     for k in sorted(env.keys()):
         if k.startswith("OPENSHIFT") or k.startswith("ANSIBLE") or k.startswith("OO"):
+            # pylint: disable=logging-format-interpolation
             installer_log.debug("{key}: {value}".format(
                 key=k, value=env[k]))
 
diff --git a/utils/test-requirements.txt b/utils/test-requirements.txt
index af91ab6a7..eeaf106ec 100644
--- a/utils/test-requirements.txt
+++ b/utils/test-requirements.txt
@@ -1,7 +1,7 @@
+ansible
 enum
 configparser
 pylint
-pep8
 nose
 coverage
 mock
-- 
cgit v1.2.3