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/n2vc/exceptions.py b/n2vc/exceptions.py
index 815d4ea..09f3573 100644
--- a/n2vc/exceptions.py
+++ b/n2vc/exceptions.py
@@ -41,7 +41,7 @@
"""The authentication for the specified user failed."""
-class NotImplemented(Exception):
+class MethodNotImplemented(Exception):
"""The method is not implemented."""
@@ -50,7 +50,7 @@
N2VC exception base class
"""
- def __init__(self, message: str = ''):
+ def __init__(self, message: str = ""):
Exception.__init__(self, message)
self.message = message
@@ -58,7 +58,7 @@
return self.message
def __repr__(self):
- return '{}({})'.format(type(self), self.message)
+ return "{}({})".format(type(self), self.message)
class N2VCBadArgumentsException(N2VCException):
@@ -66,12 +66,14 @@
Bad argument values exception
"""
- def __init__(self, message: str = '', bad_args: list = None):
+ def __init__(self, message: str = "", bad_args: list = None):
N2VCException.__init__(self, message=message)
self.bad_args = bad_args
def __str__(self):
- return '<{}> Bad arguments: {} -> {}'.format(type(self), super().__str__(), self.bad_args)
+ return "<{}> Bad arguments: {} -> {}".format(
+ type(self), super().__str__(), self.bad_args
+ )
class N2VCConnectionException(N2VCException):
@@ -79,12 +81,14 @@
Error connecting to VCA
"""
- def __init__(self, message: str = '', url: str = None):
+ def __init__(self, message: str = "", url: str = None):
N2VCException.__init__(self, message=message)
self.url = url
def __str__(self):
- return '<{}> Connection to {} failed: {}'.format(type(self), self.url, super().__str__())
+ return "<{}> Connection to {} failed: {}".format(
+ type(self), self.url, super().__str__()
+ )
class N2VCTimeoutException(N2VCException):
@@ -92,12 +96,12 @@
Timeout
"""
- def __init__(self, message: str = '', timeout: str = ''):
+ def __init__(self, message: str = "", timeout: str = ""):
N2VCException.__init__(self, message=message)
self.timeout = timeout
def __str__(self):
- return '<{}> {} timeout: {}'.format(type(self), self.timeout, super().__str__())
+ return "<{}> {} timeout: {}".format(type(self), self.timeout, super().__str__())
class N2VCExecutionException(N2VCException):
@@ -105,12 +109,14 @@
Error executing primitive
"""
- def __init__(self, message: str = '', primitive_name: str = ''):
+ def __init__(self, message: str = "", primitive_name: str = ""):
N2VCException.__init__(self, message=message)
self.primitive_name = primitive_name
def __str__(self):
- return '<{}> Error executing primitive {} failed: {}'.format(type(self), self.primitive_name, super().__str__())
+ return "<{}> Error executing primitive {} failed: {}".format(
+ type(self), self.primitive_name, super().__str__()
+ )
class N2VCInvalidCertificate(N2VCException):
@@ -118,11 +124,11 @@
Invalid certificate
"""
- def __init__(self, message: str = ''):
+ def __init__(self, message: str = ""):
N2VCException.__init__(self, message=message)
def __str__(self):
- return '<{}> Invalid certificate: {}'.format(type(self), super().__str__())
+ return "<{}> Invalid certificate: {}".format(type(self), super().__str__())
class N2VCNotFound(N2VCException):
@@ -130,11 +136,11 @@
Not found
"""
- def __init__(self, message: str = ''):
+ def __init__(self, message: str = ""):
N2VCException.__init__(self, message=message)
def __str__(self):
- return '<{}> Not found: {}'.format(type(self), super().__str__())
+ return "<{}> Not found: {}".format(type(self), super().__str__())
class K8sException(Exception):