[Python-modules-commits] [txwinrm] 03/09: Fix tests

Christopher Stuart Hoskin mans0954 at moszumanska.debian.org
Mon Jun 26 01:47:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

mans0954 pushed a commit to branch master
in repository txwinrm.

commit e8f92a5cbc1aeababcb43e40ea71433c74c19177
Author: Christopher Hoskin <christopher.hoskin at gmail.com>
Date:   Fri Jul 29 21:46:55 2016 +0100

    Fix tests
---
 setup.py                   |  1 +
 txwinrm/enumerate.py       |  8 ++++----
 txwinrm/test/test_shell.py | 12 ++++++++----
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/setup.py b/setup.py
index 9ee7008..71f9c1b 100755
--- a/setup.py
+++ b/setup.py
@@ -20,6 +20,7 @@ setup_kwargs = dict(
     url='https://github.com/zenoss/txwinrm',
     packages=['txwinrm', 'txwinrm.request'],
     package_data={'txwinrm.request': ['*.xml']},
+    test_suite='txwinrm.test',
     scripts=[
         'scripts/winrm',
         'scripts/winrs',
diff --git a/txwinrm/enumerate.py b/txwinrm/enumerate.py
index 8e379cb..78b3d50 100755
--- a/txwinrm/enumerate.py
+++ b/txwinrm/enumerate.py
@@ -325,7 +325,7 @@ class TextBufferingContentHandler(sax.handler.ContentHandler):
         This implementation saves the text from the buffer. Then it resets and
         truncates the buffer.
         """
-        self._text = self._buffer.getvalue()
+        self._text = self._buffer.getvalue().decode('utf-8')
         self._reset_truncate()
 
     def characters(self, content):
@@ -335,7 +335,7 @@ class TextBufferingContentHandler(sax.handler.ContentHandler):
 
         This implementation writes to the buffer.
         """
-        self._buffer.write(content)
+        self._buffer.write(content.encode('utf-8'))
 
     def _reset_truncate(self):
         self._buffer.reset()
@@ -599,7 +599,7 @@ class ItemsContentHandler(sax.handler.ContentHandler):
         This instance manipulates the tag stack, creating a new instance if
         it's length is 1. Saves value as None if the nil attribute is present.
         """
-        log.debug('ItemsContentHandler startElementNS {0} v="{1}" t="{2}" {3}'
+        log.debug(u'ItemsContentHandler startElementNS {0} v="{1}" t="{2}" {3}'
                   .format(name, self._value, self._text_buffer.text,
                           self._tag_stack))
         tag = create_tag_comparer(name)
@@ -624,7 +624,7 @@ class ItemsContentHandler(sax.handler.ContentHandler):
         the text as a date and saves it for later use when the properties
         element is closed.
         """
-        log.debug('ItemsContentHandler endElementNS {0} v="{1}" t="{2}" {3}'
+        log.debug(u'ItemsContentHandler endElementNS {0} v="{1}" t="{2}" {3}'
                   .format(name, self._value, self._text_buffer.text,
                           self._tag_stack))
         tag = create_tag_comparer(name)
diff --git a/txwinrm/test/test_shell.py b/txwinrm/test/test_shell.py
index 245a187..7210ea4 100644
--- a/txwinrm/test/test_shell.py
+++ b/txwinrm/test/test_shell.py
@@ -16,6 +16,7 @@ from .tools import create_get_elem_func
 from ..shell import _build_command_line_elem, _stripped_lines, \
     _find_shell_id, _find_command_id, _find_stream, _find_exit_code, \
     CommandResponse, SingleShotCommand, LongRunningCommand, Typeperf
+from ..util import EtreeRequestSender, ConnectionInfo
 
 DATADIR = os.path.join(
     os.path.dirname(os.path.abspath(__file__)), "data_shell")
@@ -36,6 +37,7 @@ class FakeRequestSender(object):
 
     hostname = 'fake_host'
     _receive_resp = 'receive_resp_01.xml'
+    _conn_info = ConnectionInfo("10.30.50.34", "kerberos", "rbooth at SOLUTIONS.LOC", "", "http", 5985, "Keep-Alive", "/home/zenoss/rbooth.keytab", '')
 
     def send_request(self, request_template_name, **kwargs):
         elem = None
@@ -50,8 +52,10 @@ class FakeRequestSender(object):
             elem = get_elem(self._receive_resp)
             self._receive_resp = 'receive_resp_02.xml'
 
-        return defer.succeed(elem)
+        return defer.returnValue(elem)
 
+    def close_connections(self):
+        return defer.succeed(None)
 
 class TestBuildCommandLineElem(unittest.TestCase):
 
@@ -148,7 +152,7 @@ class TestSingleShotCommand(unittest.TestCase):
 
     @defer.inlineCallbacks
     def test_run_command(self):
-        command = SingleShotCommand(FakeRequestSender())
+        command = SingleShotCommand(EtreeRequestSender(FakeRequestSender()))
         cmd_response = yield command.run_command('foo')
         self.assertEqual(cmd_response.exit_code, 0)
         self.assertEqual(cmd_response.stderr, [])
@@ -163,7 +167,7 @@ class TestSingleShotCommand(unittest.TestCase):
 class TestLongRunningCommand(unittest.TestCase):
 
     def setUp(self):
-        self._command = LongRunningCommand(FakeRequestSender())
+        self._command = LongRunningCommand(EtreeRequestSender(FakeRequestSender()))
 
     def tearDown(self):
         self._command = None
@@ -202,7 +206,7 @@ class TestLongRunningCommand(unittest.TestCase):
 class TestTypeperf(unittest.TestCase):
 
     def setUp(self):
-        self._command = Typeperf(LongRunningCommand(FakeRequestSender()))
+        self._command = Typeperf(LongRunningCommand(EtreeRequestSender(FakeRequestSender())))
 
     def tearDown(self):
         self._command = None

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/txwinrm.git



More information about the Python-modules-commits mailing list