From 4de95c6d2d29057f2b6e2f7367e42af0650fa73d Mon Sep 17 00:00:00 2001
From: Piotr Maslanka <piotr.maslanka@henrietta.com.pl>
Date: Tue, 10 Jan 2017 04:16:35 +0100
Subject: [PATCH] tests

---
 coolamqp/attaches/channeler.py                  | 4 +++-
 coolamqp/clustering/single.py                   | 4 +++-
 coolamqp/framing/compilation/__init__.py        | 3 ++-
 coolamqp/objects.py                             | 1 +
 tests/test_framing/test_definitions/test_cpl.py | 3 ++-
 5 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/coolamqp/attaches/channeler.py b/coolamqp/attaches/channeler.py
index 74fb96d..791f5f5 100644
--- a/coolamqp/attaches/channeler.py
+++ b/coolamqp/attaches/channeler.py
@@ -151,7 +151,9 @@ class Channeler(Attache):
 
         But moar performant.
         """
-        assert self.channel_id is not None
+        if self.channel_id is None:
+            return  # advanced teardown xD
+
         frames = [AMQPMethodFrame(self.channel_id, payload) for payload in payloads]
         self.connection.send(frames)
 
diff --git a/coolamqp/clustering/single.py b/coolamqp/clustering/single.py
index 9fbb9e2..a15b5c6 100644
--- a/coolamqp/clustering/single.py
+++ b/coolamqp/clustering/single.py
@@ -37,4 +37,6 @@ class SingleNodeReconnector(object):
 
     def shutdown(self):
         """Close this connection"""
-        self.connection.send(None)
+        if self.connection is not None:
+            self.connection.send(None)
+            self.connection = None
diff --git a/coolamqp/framing/compilation/__init__.py b/coolamqp/framing/compilation/__init__.py
index c932491..935f698 100644
--- a/coolamqp/framing/compilation/__init__.py
+++ b/coolamqp/framing/compilation/__init__.py
@@ -1,5 +1,6 @@
 # coding=UTF-8
 from __future__ import absolute_import, division, print_function
 """
-Function that compiles amqp0-9-1.xml to definitions.py
+- Compile XML to definitions.py
+- Dynamically compile classes from property_flags
 """
\ No newline at end of file
diff --git a/coolamqp/objects.py b/coolamqp/objects.py
index dda8ea5..0b911ab 100644
--- a/coolamqp/objects.py
+++ b/coolamqp/objects.py
@@ -183,6 +183,7 @@ class Future(concurrent.futures.Future):
     def result(self, timeout=None):
         assert timeout is None, u'Non-none timeouts not supported'
         self.lock.acquire()
+        self.lock.release()
 
         if self.completed:
             if self.successfully:
diff --git a/tests/test_framing/test_definitions/test_cpl.py b/tests/test_framing/test_definitions/test_cpl.py
index 03b8e9f..2f86577 100644
--- a/tests/test_framing/test_definitions/test_cpl.py
+++ b/tests/test_framing/test_definitions/test_cpl.py
@@ -1,6 +1,7 @@
 # coding=UTF-8
 from __future__ import absolute_import, division, print_function
 import unittest
+import struct
 import io
 
 
@@ -29,4 +30,4 @@ class TestBasicContentPropertyList(unittest.TestCase):
         bcpl.write_to(buf)
 
         ser = buf.getvalue()
-        self.assertEquals(ser, '\x80\x00' + chr(len('text/plain')) + b'text/plain')
+        self.assertEquals(ser, b'\x80\x00' + struct.pack('!B', len('text/plain')) + b'text/plain')
-- 
GitLab