[SEBA-450] (part 2)

Add tox testing support on additional XOS library modules:

- xos-api
- xos-kafka (has no tests)
- xos-migrate (has no tests)
- xos-synchronizer

Change-Id: I98195bc9747971d3515882d517affe058dd86ac5
diff --git a/lib/xos-api/xosapi/chameleon_client/asleep.py b/lib/xos-api/xosapi/chameleon_client/asleep.py
index 295f675..cdba793 100644
--- a/lib/xos-api/xosapi/chameleon_client/asleep.py
+++ b/lib/xos-api/xosapi/chameleon_client/asleep.py
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+from __future__ import absolute_import
 from twisted.internet import reactor
 from twisted.internet.defer import Deferred
 
@@ -25,4 +26,4 @@
     """
     d = Deferred()
     reactor.callLater(dt, lambda: d.callback(None))
-    return d
\ No newline at end of file
+    return d
diff --git a/lib/xos-api/xosapi/chameleon_client/grpc_client.py b/lib/xos-api/xosapi/chameleon_client/grpc_client.py
index a8ad69d..7d3839d 100644
--- a/lib/xos-api/xosapi/chameleon_client/grpc_client.py
+++ b/lib/xos-api/xosapi/chameleon_client/grpc_client.py
@@ -20,6 +20,7 @@
 semantics are derived from the recovered schema.
 """
 
+from __future__ import absolute_import
 import os
 import sys
 import time
@@ -33,12 +34,12 @@
 from structlog import get_logger
 from twisted.internet import reactor
 from twisted.internet.defer import inlineCallbacks, returnValue
-from werkzeug.exceptions import ServiceUnavailable
+from twisted.internet.error import ConnectError
 
-from protos.schema_pb2_grpc import SchemaServiceStub
+from .protos.schema_pb2_grpc import SchemaServiceStub
 from google.protobuf.empty_pb2 import Empty
 
-from asleep import asleep
+from .asleep import asleep
 
 log = get_logger()
 
@@ -143,14 +144,14 @@
 
             return
 
-        except _Rendezvous, e:
+        except _Rendezvous as e:
             if e.code() == grpc.StatusCode.UNAVAILABLE:
                 log.info('grpc-endpoint-not-available')
             else:
                 log.exception('rendezvous error', e=e)
             yield self._backoff('not-available')
 
-        except Exception, e:
+        except Exception:
             if not self.shutting_down:
                 log.exception('cannot-connect', endpoint=_endpoint)
             yield self._backoff('unknown-error')
@@ -277,7 +278,7 @@
                       if f.endswith('_pb2.py')]:
             modname = fname[:-len('.py')]
             log.debug('test-import', modname=modname)
-            _ = __import__(modname)
+            _ = __import__(modname)  # noqa: F841
 
     @inlineCallbacks
     def invoke(self, stub, method_name, request, metadata, retry=1):
@@ -291,17 +292,17 @@
         """
 
         if not self.connected:
-            raise ServiceUnavailable()
+            raise ConnectError()
 
         try:
             method = getattr(stub(self.channel), method_name)
             response, rendezvous = method.with_call(request, metadata=metadata)
             returnValue((response, rendezvous.trailing_metadata()))
 
-        except grpc._channel._Rendezvous, e:
+        except grpc._channel._Rendezvous as e:
             code = e.code()
             if code == grpc.StatusCode.UNAVAILABLE:
-                e = ServiceUnavailable()
+                e = ConnectError()
 
                 if self.connected:
                     self.connected = False
diff --git a/lib/xos-api/xosapi/chameleon_client/protoc_plugins/gw_gen.py b/lib/xos-api/xosapi/chameleon_client/protoc_plugins/gw_gen.py
index 9cd2f6f..cafee67 100755
--- a/lib/xos-api/xosapi/chameleon_client/protoc_plugins/gw_gen.py
+++ b/lib/xos-api/xosapi/chameleon_client/protoc_plugins/gw_gen.py
@@ -15,6 +15,7 @@
 # limitations under the License.
 #
 
+from __future__ import absolute_import
 import sys
 
 from google.protobuf.compiler import plugin_pb2 as plugin
@@ -23,7 +24,7 @@
 from jinja2 import Template
 from simplejson import dumps
 
-from xosapi.chameleon_client.protos import annotations_pb2, http_pb2
+from xosapi.chameleon_client.protos import http_pb2
 
 template = Template("""
 # Generated file; please do not edit
diff --git a/lib/xos-api/xosapi/chameleon_client/protos/annotations_pb2.py b/lib/xos-api/xosapi/chameleon_client/protos/annotations_pb2.py
index 5abc663..aa451e5 100644
--- a/lib/xos-api/xosapi/chameleon_client/protos/annotations_pb2.py
+++ b/lib/xos-api/xosapi/chameleon_client/protos/annotations_pb2.py
@@ -18,6 +18,7 @@
 # Generated by the protocol buffer compiler.  DO NOT EDIT!
 # source: annotations.proto
 
+from __future__ import absolute_import
 import sys
 _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
 from google.protobuf import descriptor as _descriptor
@@ -30,7 +31,7 @@
 _sym_db = _symbol_database.Default()
 
 
-import http_pb2 as http__pb2
+from . import http_pb2 as http__pb2
 from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2
 
 
diff --git a/lib/xos-api/xosapi/chameleon_client/protos/annotations_pb2_grpc.py b/lib/xos-api/xosapi/chameleon_client/protos/annotations_pb2_grpc.py
index 972edf5..1ec9f40 100644
--- a/lib/xos-api/xosapi/chameleon_client/protos/annotations_pb2_grpc.py
+++ b/lib/xos-api/xosapi/chameleon_client/protos/annotations_pb2_grpc.py
@@ -16,4 +16,5 @@
 #
 
 # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
+from __future__ import absolute_import
 import grpc
diff --git a/lib/xos-api/xosapi/chameleon_client/protos/http_pb2.py b/lib/xos-api/xosapi/chameleon_client/protos/http_pb2.py
index f420e61..8e359f5 100644
--- a/lib/xos-api/xosapi/chameleon_client/protos/http_pb2.py
+++ b/lib/xos-api/xosapi/chameleon_client/protos/http_pb2.py
@@ -18,6 +18,7 @@
 # Generated by the protocol buffer compiler.  DO NOT EDIT!
 # source: http.proto
 
+from __future__ import absolute_import
 import sys
 _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
 from google.protobuf import descriptor as _descriptor
diff --git a/lib/xos-api/xosapi/chameleon_client/protos/http_pb2_grpc.py b/lib/xos-api/xosapi/chameleon_client/protos/http_pb2_grpc.py
index 972edf5..1ec9f40 100644
--- a/lib/xos-api/xosapi/chameleon_client/protos/http_pb2_grpc.py
+++ b/lib/xos-api/xosapi/chameleon_client/protos/http_pb2_grpc.py
@@ -16,4 +16,5 @@
 #
 
 # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
+from __future__ import absolute_import
 import grpc
diff --git a/lib/xos-api/xosapi/chameleon_client/protos/schema_pb2.py b/lib/xos-api/xosapi/chameleon_client/protos/schema_pb2.py
index 06909b4..0e0159a 100644
--- a/lib/xos-api/xosapi/chameleon_client/protos/schema_pb2.py
+++ b/lib/xos-api/xosapi/chameleon_client/protos/schema_pb2.py
@@ -18,6 +18,7 @@
 # Generated by the protocol buffer compiler.  DO NOT EDIT!
 # source: schema.proto
 
+from __future__ import absolute_import
 import sys
 _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
 from google.protobuf import descriptor as _descriptor
diff --git a/lib/xos-api/xosapi/chameleon_client/protos/schema_pb2_grpc.py b/lib/xos-api/xosapi/chameleon_client/protos/schema_pb2_grpc.py
index 65c9afa..06c1456 100644
--- a/lib/xos-api/xosapi/chameleon_client/protos/schema_pb2_grpc.py
+++ b/lib/xos-api/xosapi/chameleon_client/protos/schema_pb2_grpc.py
@@ -16,10 +16,11 @@
 #
 
 # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
+from __future__ import absolute_import
 import grpc
 
 from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
-import schema_pb2 as schema__pb2
+from . import schema_pb2 as schema__pb2
 
 
 class SchemaServiceStub(object):