Enable lint, flake8 and unit tests

Cleans up non pep compliant code.
Adds a simple unit test.
Formats according to black.

Tox automatically runs lint, flake8 and unit test suite
with coverage.  To run each individually, execute:

tox -e pylint
tox -e black
tox -e flake8
tox -e cover

Note that these are all run for each patch via Jenkins.  The full
tox suite should be run locally before any commit to ensure it
will not fail in Jenkins.

Change-Id: I2f87abe3d5086d6d65ac33a27780c498fc7b1cd3
Signed-off-by: beierlm <mark.beierl@canonical.com>
diff --git a/tox.ini b/tox.ini
index 4685666..bd89241 100644
--- a/tox.ini
+++ b/tox.ini
@@ -12,66 +12,56 @@
 #     See the License for the specific language governing permissions and
 #     limitations under the License.
 
-# Tox (http://tox.testrun.org/) is a tool for running tests
-# in multiple virtualenvs. This configuration file will run the
-# test suite on all supported python versions. To use it, "pip install tox"
-# and then run "tox" from this directory.
-
 [tox]
-envlist = py3,lint,integration
-skipsdist=True
-
-[pytest]
-markers =
-    serial: mark a test that must run by itself
+envlist = cover, flake8, pylint
 
 [testenv]
-basepython=python3
-usedevelop=True
 
-# for testing with other python versions
-commands = py.test --ignore modules/ --ignore tests/charms/ --tb native -ra -v -s -n auto -k 'not integration' -m 'not serial' {posargs}
-passenv =
-    HOME
-    VCA_PATH
-    VCA_HOST
-    VCA_PORT
-    VCA_USER
-    VCA_SECRET
-    LXD_HOST
-    LXD_SECRET
-    VCA_CACERT
-    # These are needed so executing `charm build` succeeds
-    TERM
-    TERMINFO
+[testenv:cover]
+basepython = python3
 deps =
-    mock
-    pyyaml
-    pytest
-    pytest-asyncio
-    pytest-xdist
-    pytest-assume
-    paramiko
-    pylxd
-
-[testenv:py3]
-# default tox env, excludes integration and serial tests
+  nose2
+  -rrequirements.txt
+  -rtest-requirements.txt
 commands =
-    pytest --ignore modules/ --ignore tests/charms/ --tb native -ra -v -n auto -k 'not integration' -m 'not serial' {posargs}
+  coverage erase
+  nose2 -C --coverage n2vc --plugin nose2.plugins.junitxml -s n2vc
+  coverage report --omit='*tests*'
+  coverage html -d ./cover --omit='*tests*'
+  coverage xml -o coverage.xml --omit='*tests*'
 
-[testenv:lint]
-envdir = {toxworkdir}/py3
-commands =
-    flake8 --ignore E501,E402 --exclude tests/charms/builds,tests/charms/deps {posargs} n2vc tests
+[testenv:pylint]
+basepython = python3
 deps =
-    flake8
+  pylint
+  -rrequirements.txt
+commands =
+  pylint -E n2vc
 
-[testenv:integration]
-envdir = {toxworkdir}/py3
-commands = py.test --ignore modules/  --ignore tests/charms/ --tb native -ra -v -s -n 1 -k 'integration' -m 'serial' {posargs}
+[testenv:black]
+basepython = python3
+deps =
+  black
+commands =
+  black --check --diff n2vc
+
+[testenv:flake8]
+basepython = python3
+deps =
+  flake8
+  -rrequirements.txt
+commands =
+  flake8 n2vc
+
+[flake8]
+# W503 is invalid PEP-8
+max-line-length = 88
+show-source = True
+ignore = W503,E203
+exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,devops_stages/*,.rst
 
 [testenv:build]
 deps =
-    stdeb
-    setuptools-version-command
+  stdeb
+  setuptools-version-command
 commands = python3 setup.py --command-packages=stdeb.command bdist_deb