Author: aconway
Date: Tue Jul  8 20:33:51 2014
New Revision: 1608953

URL: http://svn.apache.org/r1608953
Log:
NO-JIRA: Python import cleanup, move test stubs to tests directory.

Get rid of import *
Move stub objects for tests from production code to tests/mock directory.
Move libqpid_dispatch.py library stubs to ../dispatch_c.py
Separate config file parsig from qdrouter-specific schema code.

Added:
    qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py
      - copied, changed from r1608952, 
qpid/dispatch/trunk/python/qpid_dispatch_internal/management/libqpid_dispatch.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py
      - copied, changed from r1608952, 
qpid/dispatch/trunk/python/qpid_dispatch_internal/management/qdrouter.py
    qpid/dispatch/trunk/tests/mock/dispatch.py
      - copied, changed from r1608952, 
qpid/dispatch/trunk/python/qpid_dispatch_internal/stubs/ioadapter.py
Removed:
    
qpid/dispatch/trunk/python/qpid_dispatch_internal/management/libqpid_dispatch.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/stubs/__init__.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/stubs/ioadapter.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/stubs/logadapter.py
Modified:
    qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/__init__.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/management/__init__.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/management/qdrouter.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/__init__.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/data.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/link.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/message.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/mobile.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/neighbor.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/node.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/path.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/router/routing.py
    qpid/dispatch/trunk/python/qpid_dispatch_internal/tools/__init__.py
    qpid/dispatch/trunk/tests/management/__init__.py
    qpid/dispatch/trunk/tests/management/qdrouter.py
    qpid/dispatch/trunk/tests/management/schema.py
    qpid/dispatch/trunk/tests/router_engine_test.py
    qpid/dispatch/trunk/tests/run_system_tests.py
    qpid/dispatch/trunk/tests/system_test.py
    qpid/dispatch/trunk/tests/system_tests_management.py

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/__init__.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/__init__.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/__init__.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/__init__.py Tue 
Jul  8 20:33:51 2014
@@ -19,5 +19,14 @@
 
 """Compatibility hacks for older versions of python"""
 
+import sys
+
+__all__ = ["OrderedDict"]
+
 try: from collections import OrderedDict
 except: from ordereddict import OrderedDict
+
+if sys.version_info >= (2,7):
+    json_load_kwargs = {'object_pairs_hook':OrderedDict}
+else:
+    json_load_kwargs = {}

Copied: qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py (from 
r1608952, 
qpid/dispatch/trunk/python/qpid_dispatch_internal/management/libqpid_dispatch.py)
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py?p2=qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py&p1=qpid/dispatch/trunk/python/qpid_dispatch_internal/management/libqpid_dispatch.py&r1=1608952&r2=1608953&rev=1608953&view=diff
==============================================================================
--- 
qpid/dispatch/trunk/python/qpid_dispatch_internal/management/libqpid_dispatch.py
 (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/dispatch_c.py Tue Jul  8 
20:33:51 2014
@@ -17,9 +17,7 @@
 # under the License
 #
 
-"""Access to fucntions in libqpid-dispatch.so"""
-
-# TODO aconway 2014-06-19: this is all linux specific.
+"""Access to functions in libqpid-dispatch.so"""
 
 import ctypes, os
 from ctypes import c_char_p, c_long, py_object

Modified: 
qpid/dispatch/trunk/python/qpid_dispatch_internal/management/__init__.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/__init__.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/__init__.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/__init__.py 
Tue Jul  8 20:33:51 2014
@@ -18,7 +18,11 @@
 #
 """Management package"""
 
-from .entity import *
-from .node import *
-from .qdrouter import *
-from .schema import *
+
+from .entity import Entity, EntityList
+from .node import ManagementError, Node, Url
+from .qdrouter import QdSchema
+from .config import Config, configure_dispatch
+from .schema import Type, BooleanType, EnumType, EnumValue, AttributeType, 
EntityType, Schema, schema_file, ValidationError
+
+__all__ = ["Entity", "EntityList", "ManagementError", "Node", "Url", 
"QdSchema", "Config", "configure_dispatch", "Type", "BooleanType", "EnumType", 
"EnumValue", "AttributeType", "EntityType", "Schema", "schema_file", 
"ValidationError"]

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/agent.py Tue 
Jul  8 20:33:51 2014
@@ -18,7 +18,7 @@
 #
 
 import httplib, re
-import libqpid_dispatch
+from qpid_dispatch_internal import dispatch_c
 from dispatch import IoAdapter, LogAdapter, LOG_DEBUG, LOG_ERROR
 from node import ManagementError
 from schema import ValidationError
@@ -30,7 +30,7 @@ from traceback import format_exc
 
 class Agent(object):
     def __init__(self, dispatch):
-        self.qd = libqpid_dispatch.instance()
+        self.qd = dispatch_c.instance()
         self.dispatch = self.qd.qd_dispatch_p(dispatch)
         # FIXME aconway 2014-06-26: $management
         self.io = [IoAdapter(self.receive, "$management2"),

Copied: qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py 
(from r1608952, 
qpid/dispatch/trunk/python/qpid_dispatch_internal/management/qdrouter.py)
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py?p2=qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py&p1=qpid/dispatch/trunk/python/qpid_dispatch_internal/management/qdrouter.py&r1=1608952&r2=1608953&rev=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/qdrouter.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/config.py Tue 
Jul  8 20:33:51 2014
@@ -1,69 +1,35 @@
-##
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements.  See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership.  The ASF licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License.  You may obtain a copy of the License at
-##
-##   http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing,
-## software distributed under the License is distributed on an
-## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-## KIND, either express or implied.  See the License for the
-## specific language governing permissions and limitations
-## under the License
-##
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License
+#
 
 """
-Qpid Dispatch Router management schema and config file parsing.
+Configuration file parsing
 """
 
 import json, re, sys
 import schema
-from entity import EntityList, Entity, OrderedDict
 from copy import copy
-import libqpid_dispatch
+from qpid_dispatch_internal import dispatch_c
+from .entity import EntityList, Entity
+from .qdrouter import QdSchema
+from ..compat import json_load_kwargs
 
-if sys.version_info >= (2,7):
-    json_load_kwargs = {'object_pairs_hook':OrderedDict}
-else:
-    json_load_kwargs = {}
-
-class QdSchema(schema.Schema):
-    """
-    Qpid Dispatch Router management schema.
-    """
-    SCHEMA_FILE = schema.schema_file("qdrouter.json")
-
-    def __init__(self):
-        """Load schema."""
-        with open(self.SCHEMA_FILE) as f:
-            super(QdSchema, self).__init__(**json.load(f, **json_load_kwargs))
-
-    def validate(self, entities, full=True, **kwargs):
-        """
-        In addition to L{schema.Schema.validate}, check the following:
-
-        If the operating mode of the router is not 'interior', then the only
-        permitted roles for listeners and connectors is 'normal'.
-
-        @param entities: An L{EntityList}
-        @param full: Perform validation for full configuration.
-        @param kwargs: See L{schema.Schema.validate}
-        """
-        super(QdSchema, self).validate(entities, **kwargs)
-
-        if full:
-            if entities.router[0].mode != 'interior':
-                for connect in entities.get(entity_type='listeners') + 
entities.get(entity_type='connector'):
-                    if connect['role'] != 'normal':
-                        raise schema.ValidationError("Role '%s' for entity 
'%s' only permitted with 'interior' mode % (entity['role'], connect.name)")
-
-
-class QdConfig(EntityList):
+class Config(EntityList):
     """An L{EntityList} loaded from a qdrouterd.conf and validated against 
L{QdSchema}."""
 
     def __init__(self, filename=None, schema=QdSchema()):
@@ -176,9 +142,9 @@ class QdConfig(EntityList):
 
 def configure_dispatch(dispatch, filename):
     """Called by C router code to load configuration file and do 
configuration"""
-    qd = libqpid_dispatch.instance()
+    qd = dispatch_c.instance()
     dispatch = qd.qd_dispatch_p(dispatch)
-    config = QdConfig(filename)
+    config = Config(filename)
     # Configure any DEFAULT log entities first so we can report errors in non-
     # default log configurations to the correct place.
     for l in config.log:

Modified: 
qpid/dispatch/trunk/python/qpid_dispatch_internal/management/qdrouter.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/management/qdrouter.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/management/qdrouter.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/management/qdrouter.py 
Tue Jul  8 20:33:51 2014
@@ -21,16 +21,9 @@
 Qpid Dispatch Router management schema and config file parsing.
 """
 
-import json, re, sys
+import json
 import schema
-from entity import EntityList, Entity, OrderedDict
-from copy import copy
-import libqpid_dispatch
-
-if sys.version_info >= (2,7):
-    json_load_kwargs = {'object_pairs_hook':OrderedDict}
-else:
-    json_load_kwargs = {}
+from ..compat import json_load_kwargs
 
 class QdSchema(schema.Schema):
     """
@@ -61,137 +54,3 @@ class QdSchema(schema.Schema):
                 for connect in entities.get(entity_type='listeners') + 
entities.get(entity_type='connector'):
                     if connect['role'] != 'normal':
                         raise schema.ValidationError("Role '%s' for entity 
'%s' only permitted with 'interior' mode % (entity['role'], connect.name)")
-
-
-class QdConfig(EntityList):
-    """An L{EntityList} loaded from a qdrouterd.conf and validated against 
L{QdSchema}."""
-
-    def __init__(self, filename=None, schema=QdSchema()):
-        self.schema = schema
-        if filename: self.load(filename)
-
-    @staticmethod
-    def _parse(lines):
-        """Parse config file format into a section list"""
-        begin = re.compile(r'([\w-]+)[ \t]*{') # WORD {
-        end = re.compile(r'}')                 # }
-        attr = re.compile(r'([\w-]+)[ \t]*:[ \t]*(.+)') # WORD1: VALUE
-
-        def sub(line):
-            """Do substitutions to make line json-friendly"""
-            line = line.split('#')[0].strip() # Strip comments
-            line = re.sub(begin, r'["\1", {', line)
-            line = re.sub(end, r'}],', line)
-            line = re.sub(attr, r'"\1": "\2",', line)
-            return line
-
-        js_text = "[%s]"%("".join([sub(l) for l in lines]))
-        spare_comma = re.compile(r',\s*([]}])') # Strip spare commas
-        js_text = re.sub(spare_comma, r'\1', js_text)
-        return json.loads(js_text, **json_load_kwargs)
-
-    def _expand(self, content):
-        """
-        Find include sections (defined by schema) in the content,
-        expand references and remove the include sections.
-        @param content: ((section-name:{name:value...}))
-        """
-        def _expand_section(section, includes):
-            """Expand one section"""
-            attrs = section[1]
-            for k in attrs.keys(): # Iterate over keys() because we will 
modify attr
-                inc = [i[1] for i in includes if i[0] == k and i[1]['name'] == 
attrs[k]]
-                if inc:
-                    assert len(inc) == 1
-                    inc = copy(inc[0])
-                    del inc['name'] # Not a real attribute, just an include id.
-                    attrs.update(inc)
-                    del attrs[k] # Delete the include attribute.
-            return section
-        includes = [s for s in content if s[0] in self.schema.includes]
-        return [_expand_section(s, includes) for s in content if s[0] not in 
self.schema.includes]
-
-    def _default_ids(self, content):
-        """
-        Set default name and identity where missing.
-        - If entity has no name/identity, set both to "<entity-type>-<i>"
-        - If entity has one of name/identity set the other to be the same.
-        - If entity has both, do nothing
-        """
-        counts = dict((e, 0) for e in self.schema.entity_types)
-        for section in content:
-            entity_type, attrs = section
-            count = counts[entity_type]
-            counts[entity_type] += 1
-            if 'name' in attrs and 'identity' in attrs:
-                continue
-            elif 'name' in attrs:
-                attrs['identity'] = attrs['name']
-            elif 'identity' in attrs:
-                attrs['name'] = attrs['identity']
-            else:
-                identity = "%s%d"%(entity_type, count)
-                attrs['name'] = attrs['identity'] = identity
-        return content
-
-    def load(self, source):
-        """
-        Load a configuration file.
-        @param source: A file name, open file object or iterable list of lines
-        """
-        if isinstance(source, basestring):
-            with open(source) as f:
-                try:
-                    self.load(f)
-                except:
-                    ex_type, ex_value, ex_trace = sys.exc_info()
-                    raise schema.ValidationError, "Loading '%s', %s: 
%s"%(source, ex_type.__name__, ex_value), ex_trace
-        else:
-            sections = self._parse(source);
-            # Add missing singleton sections
-            for et in self.schema.entity_types.itervalues():
-                if et.singleton and not [s for s in sections if s[0] == 
et.name]:
-                    sections.append((et.name, {}))
-            sections = self._expand(sections)
-            sections = self._default_ids(sections)
-            self[:] = [Entity(type=s[0], **s[1]) for s in sections]
-            self.validate(self.schema)
-
-    def section_count(self, section):
-        return len(self.get(type=section))
-
-    def entity(self, section, index):
-        return self.get(type=section)[index]
-
-    def value(self, section, index, key, convert=lambda x: x):
-        """
-        @return: Value at section, index, key or None if absent.
-        @param as_type: A callable to convert the result to some type.
-        """
-        entities = self.get(type=section)
-        if len(entities) <= index or key not in entities[index]:
-            return None
-        return convert(entities[index][key])
-
-
-def configure_dispatch(dispatch, filename):
-    """Called by C router code to load configuration file and do 
configuration"""
-    qd = libqpid_dispatch.instance()
-    dispatch = qd.qd_dispatch_p(dispatch)
-    config = QdConfig(filename)
-    # Configure any DEFAULT log entities first so we can report errors in non-
-    # default log configurations to the correct place.
-    for l in config.log:
-        if l.module.upper() == 'DEFAULT': qd.qd_log_entity(l)
-    for l in config.log:
-        if l.module.upper() != 'DEFAULT': qd.qd_log_entity(l)
-    qd.qd_dispatch_configure_container(dispatch, config.container[0])
-    qd.qd_dispatch_configure_router(dispatch, config.router[0])
-    qd.qd_dispatch_prepare(dispatch)
-    # Note must configure addresses, waypoints, listeners and connectors after 
qd_dispatch_prepare
-    for a in config.get(type='fixed-address'): 
qd.qd_dispatch_configure_address(dispatch, a)
-    for w in config.waypoint: qd.qd_dispatch_configure_waypoint(dispatch, w)
-    for l in config.listener: qd.qd_dispatch_configure_listener(dispatch, l)
-    for c in config.connector: qd.qd_dispatch_configure_connector(dispatch, c)
-    qd.qd_connection_manager_start(dispatch);
-    qd.qd_waypoint_activate_all(dispatch);

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/__init__.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/__init__.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/__init__.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/__init__.py Tue 
Jul  8 20:33:51 2014
@@ -17,4 +17,6 @@
 # under the License.
 #
 
-from .engine import *
+from .engine import RouterEngine
+
+__all__ = ["RouterEngine"]

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/data.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/data.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/data.py (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/data.py Tue Jul  8 
20:33:51 2014
@@ -17,13 +17,6 @@
 # under the License.
 #
 
-
-try:
-    from dispatch import *
-except ImportError:
-    from ..stubs import *
-
-
 def getMandatory(data, key, cls=None):
     """
     Get the value mapped to the requested key.    If it's not present, raise 
an exception.
@@ -278,4 +271,3 @@ class MessageMAR(object):
         return {'id'       : self.id,
                 'area'     : self.area,
                 'have_seq' : self.have_seq}
-

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/engine.py Tue Jul  
8 20:33:51 2014
@@ -36,11 +36,7 @@ import traceback
 ## Import the Dispatch adapters from the environment.  If they are not found
 ## (i.e. we are in a test bench, etc.), load the stub versions.
 ##
-try:
-    from dispatch import IoAdapter, LogAdapter, LOG_TRACE, LOG_DEBUG, 
LOG_INFO, LOG_ERROR
-except ImportError:
-    from ..stubs import IoAdapter, LogAdapter, LOG_TRACE, LOG_DEBUG, LOG_INFO, 
LOG_ERROR
-
+from dispatch import IoAdapter, LogAdapter, LOG_TRACE, LOG_DEBUG, LOG_INFO, 
LOG_ERROR
 
 class RouterEngine:
     """

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/link.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/link.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/link.py (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/link.py Tue Jul  8 
20:33:51 2014
@@ -18,12 +18,7 @@
 #
 
 from data import MessageRA, MessageLSU, MessageLSR
-from time import time
-
-try:
-    from dispatch import *
-except ImportError:
-    from ..stubs import *
+from dispatch import LOG_INFO
 
 class LinkStateEngine(object):
     """

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/message.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/message.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/message.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/message.py Tue Jul 
 8 20:33:51 2014
@@ -38,10 +38,10 @@ class Message(object):
     def __init__(self, **kwds):
         """All instance variables can be set as keywords. See L{Message}"""
         for f in self._fields:
-            setattr(self, f, None)
-        for k, v in kwds.iteritems():
-            getattr(self, k)    # Check for bad attributes.
-            setattr(self, k, v)
+            setattr(self, f, kwds.get(f, None))
+        for k in kwds:
+            getattr(self, k)    # Check for bad attributes
 
     def __repr__(self):
-        return "Message(%s)"%', '.join('%s=%s'%(f,getattr(self, f)) for f in 
self._fields)
+        return "%s(%s)" % (type(self).__name__,
+                           ", ".join("%s=%r"%(f, getattr(self, f)) for f in 
self._fields))

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/mobile.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/mobile.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/mobile.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/mobile.py Tue Jul  
8 20:33:51 2014
@@ -17,12 +17,8 @@
 # under the License.
 #
 
-from data import MessageRA, MessageMAR, MessageMAU
-
-try:
-    from dispatch import *
-except ImportError:
-    from ..stubs import *
+from data import MessageMAR, MessageMAU
+from dispatch import LOG_DEBUG
 
 class MobileAddressEngine(object):
     """
@@ -187,4 +183,3 @@ class MobileAddressEngine(object):
         if deleted != None:
             for d in deleted:
                 self.container.router_adapter.unmap_destination(d[0], d[1:], 
bit)
-

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/neighbor.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/neighbor.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/neighbor.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/neighbor.py Tue 
Jul  8 20:33:51 2014
@@ -18,13 +18,7 @@
 #
 
 from data import LinkState, MessageHELLO
-from time import time
-
-try:
-    from dispatch import *
-except ImportError:
-    from ..stubs import *
-
+from dispatch import LOG_INFO
 
 class NeighborEngine(object):
     """
@@ -86,4 +80,3 @@ class NeighborEngine(object):
                 to_delete.append(key)
         for key in to_delete:
             self._delete_neighbor(key)
-

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/node.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/node.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/node.py (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/node.py Tue Jul  8 
20:33:51 2014
@@ -17,12 +17,6 @@
 # under the License.
 #
 
-try:
-    from dispatch import *
-except ImportError:
-    from ..stubs import *
-
-
 class NodeTracker(object):
     """
     This module is responsible for tracking the set of router nodes that are 
known to this
@@ -183,4 +177,3 @@ class RemoteNode(object):
         self.remote   = not neighbor
         self.link_id  = link_id
         self.addrs    = {}  # Address => Count at Node (1 only for the present)
-

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/path.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/path.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/path.py (original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/path.py Tue Jul  8 
20:33:51 2014
@@ -17,10 +17,6 @@
 # under the License.
 #
 
-try:
-    from dispatch import *
-except ImportError:
-    from ..stubs import *
 
 class PathEngine(object):
     """
@@ -232,4 +228,3 @@ class NodeSet(object):
             index += 1
 
         self.nodes.insert(index, (_id, new_cost))
-

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/router/routing.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/router/routing.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/router/routing.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/router/routing.py Tue Jul 
 8 20:33:51 2014
@@ -17,11 +17,6 @@
 # under the License.
 #
 
-try:
-    from dispatch import *
-except ImportError:
-    from ..stubs import *
-
 class RoutingTableEngine(object):
     """
     This module is responsible for converting the set of next hops to remote 
routers to a routing
@@ -62,4 +57,3 @@ class RoutingTableEngine(object):
 
     def get_next_hops(self):
         return self.next_hops
-

Modified: qpid/dispatch/trunk/python/qpid_dispatch_internal/tools/__init__.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/tools/__init__.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/tools/__init__.py 
(original)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/tools/__init__.py Tue Jul 
 8 20:33:51 2014
@@ -6,9 +6,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -17,5 +17,6 @@
 # under the License.
 #
 
-from .display import *
+from .display import Display, Header, Sorter, YN, Commas, TimeLong, TimeShort, 
Sortable
 
+__all__ = ["Display", "Header", "Sorter", "YN", "Commas", "TimeLong", 
"TimeShort", "Sortable"]

Modified: qpid/dispatch/trunk/tests/management/__init__.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/management/__init__.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/management/__init__.py (original)
+++ qpid/dispatch/trunk/tests/management/__init__.py Tue Jul  8 20:33:51 2014
@@ -17,8 +17,9 @@
 ## under the License
 ##
 
-#pylint: disable=wildcard-import,missing-docstring
-from entity import *
-from schema import *
-from node import *
-from qdrouter import *
+from entity import EntityTest
+from schema import SchemaTest
+from node import UrlTest
+from qdrouter import QdrouterTest
+
+__all__ = ["EntityTest", "SchemaTest", "UrlTest", "QdrouterTest"]

Modified: qpid/dispatch/trunk/tests/management/qdrouter.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/management/qdrouter.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/management/qdrouter.py (original)
+++ qpid/dispatch/trunk/tests/management/qdrouter.py Tue Jul  8 20:33:51 2014
@@ -20,13 +20,13 @@
 #pylint: 
disable=wildcard-import,unused-wildcard-import,missing-docstring,too-many-public-methods
 
 import unittest
-from qpid_dispatch_internal.management import QdSchema, QdConfig
+from qpid_dispatch_internal.management import Config
 
 class QdrouterTest(unittest.TestCase):
     """Tests for qpid_dispatch_internal.config.qdrouter"""
 
     def test_qdrouter_parse(self):
-        conf = QdConfig()
+        conf = Config()
         conf_text = """
 # Line comment
 router {

Modified: qpid/dispatch/trunk/tests/management/schema.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/management/schema.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/management/schema.py (original)
+++ qpid/dispatch/trunk/tests/management/schema.py Tue Jul  8 20:33:51 2014
@@ -21,7 +21,7 @@
 #pylint: disable=wildcard-import,missing-docstring,too-many-public-methods
 
 import unittest, json
-from qpid_dispatch_internal.management import Schema, Entity, EntityType, 
BooleanType, EnumType, AttributeType, schema_file, ValidationError, EnumValue
+from qpid_dispatch_internal.management import Schema, BooleanType, EnumType, 
AttributeType, schema_file, ValidationError, EnumValue, EntityType, Entity
 import collections
 
 def replace_od(thing):

Copied: qpid/dispatch/trunk/tests/mock/dispatch.py (from r1608952, 
qpid/dispatch/trunk/python/qpid_dispatch_internal/stubs/ioadapter.py)
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/mock/dispatch.py?p2=qpid/dispatch/trunk/tests/mock/dispatch.py&p1=qpid/dispatch/trunk/python/qpid_dispatch_internal/stubs/ioadapter.py&r1=1608952&r2=1608953&rev=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/stubs/ioadapter.py 
(original)
+++ qpid/dispatch/trunk/tests/mock/dispatch.py Tue Jul  8 20:33:51 2014
@@ -1,4 +1,3 @@
-#
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -17,6 +16,25 @@
 # under the License.
 #
 
+"""
+Mock implementation of the dispatch C extension module for use in unit tests.
+"""
+
+LOG_TRACE    = 1
+LOG_DEBUG    = 2
+LOG_INFO     = 4
+LOG_NOTICE   = 8
+LOG_WARNING  = 16
+LOG_ERROR    = 32
+LOG_CRITICAL = 64
+
+class LogAdapter:
+  def __init__(self, mod_name):
+    self.mod_name = mod_name
+
+  def log(self, level, text):
+    print "LOG: mod=%s level=%d text=%s" % (self.mod_name, level, text)
+
 class IoAdapter:
   def __init__(self, handler, address, global_address=False):
     self.handler = handler

Modified: qpid/dispatch/trunk/tests/router_engine_test.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/router_engine_test.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/router_engine_test.py (original)
+++ qpid/dispatch/trunk/tests/router_engine_test.py Tue Jul  8 20:33:51 2014
@@ -22,6 +22,7 @@ import sys
 import unittest
 
 sys.path.append(os.path.join(os.environ["SOURCE_DIR"], "python"))
+sys.path.append(os.path.join(os.path.dirname(__file__), "mock")) # Mock 
modules for tests
 
 from qpid_dispatch_internal.router.engine import NeighborEngine, PathEngine, 
Configuration, NodeTracker
 from qpid_dispatch_internal.router.data import LinkState, MessageHELLO
@@ -167,7 +168,7 @@ class NodeTrackerTest(unittest.TestCase)
         self.reset()
         try:
             tracker.new_neighbor('E', 9)
-            AssertFalse("We shouldn't be here")
+            self.fail("We shouldn't be here")
         except:
             pass
 
@@ -354,7 +355,7 @@ class PathTest(unittest.TestCase):
     def valid_origins_changed(self, vo):
         self.valid_origins = vo
 
-    def test_topology1(self): 
+    def test_topology1(self):
         """
 
         +====+      +----+      +----+

Modified: qpid/dispatch/trunk/tests/run_system_tests.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/run_system_tests.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/run_system_tests.py (original)
+++ qpid/dispatch/trunk/tests/run_system_tests.py Tue Jul  8 20:33:51 2014
@@ -25,8 +25,8 @@ Note that each system test is an executa
 import os
 import sys
 from fnmatch import fnmatch
-import runpy
 import unittest
+
 # Collect all system_tests_*.py scripts in the same directory as this script.
 test_dir = os.path.normpath(os.path.dirname(__file__))
 test_modules = [os.path.splitext(f)[0] for f in os.listdir(test_dir) if 
fnmatch(f, "system_tests_*.py")]

Modified: qpid/dispatch/trunk/tests/system_test.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_test.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_test.py (original)
+++ qpid/dispatch/trunk/tests/system_test.py Tue Jul  8 20:33:51 2014
@@ -52,7 +52,7 @@ export PYTHONPATH="$PYTHONPATH:/usr/loca
 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib64"
 """
 
-import os, time, socket, random, subprocess, shutil, unittest, inspect
+import os, time, socket, random, subprocess, shutil, unittest
 from copy import copy
 import proton
 from proton import Message

Modified: qpid/dispatch/trunk/tests/system_tests_management.py
URL: 
http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_management.py?rev=1608953&r1=1608952&r2=1608953&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_management.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_management.py Tue Jul  8 20:33:51 
2014
@@ -19,9 +19,9 @@
 
 """System tests for management of qdrouter"""
 
-import unittest, system_test, re, os, time
+import unittest, system_test, re, os
 from qpid_dispatch_internal.management import Node, ManagementError, Url
-from system_test import Qdrouterd, message, retry, MISSING_REQUIREMENTS
+from system_test import Qdrouterd, message, retry
 from httplib import BAD_REQUEST, NOT_IMPLEMENTED
 
 class ManagementTest(system_test.TestCase): # pylint: 
disable=too-many-public-methods
@@ -153,7 +153,6 @@ class ManagementTest(system_test.TestCas
             ('fixed-address', {'prefix':'foo'})
         ])
         wp_router = self.qdrouterd('wp-router', conf)
-        wp_node = self.cleanup(Node(self.router.addresses[0]))
         wp_router.wait_ready()
 
         # Configure the router



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to