Commit b90579d3 authored by aikchar's avatar aikchar Committed by GitHub

Merge pull request #7 from codeghar/fix-gh-1-add-purge-request

Fix GH-6: add purge request
parents 1bb033d0 b8ae36ac
......@@ -15,7 +15,7 @@ class RequestCmd:
self.query_properties = {"x-amqp-0-10.app-id": "qmf2", "qmf.opcode": "_query_request", "method": "request"}
logger.debug("Message properties -> {0}".format(self.query_properties))
def create_queue(self, name, strict=True, auto_delete=False, auto_delete_timeout=10):
def create_queue(self, name, strict=True, auto_delete=False, auto_delete_timeout=0):
"""Create message content and properties to create queue with QMFv2
:param name: Name of queue to create
......@@ -118,7 +118,7 @@ class RequestCmd:
"_method_name": "delete",
"_arguments": {"type": "queue",
"name": name,
"options": dict()}}
"options": dict()}} # "A nested map with the key options. This is presently unused."
logger.debug("Message content -> {0}".format(content))
return content, self.method_properties
......@@ -133,7 +133,8 @@ class RequestCmd:
"""
content = {"_object_id": {"_object_name": self.object_name},
"_method_name": "delete",
"_arguments": {"type": "exchange", "name": name, "options": dict()}}
"_arguments": {"type": "exchange", "name": name,
"options": dict()}} # "A nested map with the key options. This is presently unused."
logger.debug("Message content -> {0}".format(content))
return content, self.method_properties
......@@ -174,3 +175,20 @@ class RequestCmd:
logger.debug("Message content -> {0}".format(content))
return content, self.query_properties
def purge_queue(self, name):
"""Create message content and properties to purge queue with QMFv2
:param name: Name of queue to purge
:type name: str
:returns: Tuple containing content and method properties
"""
content = {"_object_id": {"_object_name": "org.apache.qpid.broker:queue:{0}".format(name)},
"_method_name": "purge",
"_arguments": {"type": "queue",
"name": name,
"filter": dict()}}
logger.debug("Message content -> {0}".format(content))
return content, self.method_properties
......@@ -32,14 +32,20 @@ class Example1(MessagingHandler):
logger.debug("url {0}".format(self.url))
reqcmd = RequestCmd()
self.request_messages = [reqcmd.list_queues(),
reqcmd.create_queue("MYFIRSTQUEUE"),
reqcmd.list_queues(),
reqcmd.delete_queue("MYFIRSTQUEUE"),
reqcmd.list_exchanges(),
reqcmd.create_exchange("MYFIRSTEXCAHNGE"),
reqcmd.list_exchanges(),
reqcmd.delete_exchange("MYFIRSTEXCAHNGE")]
myfirstqueue = "MYFIRSTQUEUE"
myfirstexchange = "MYFIRSTEXCAHNGE"
self.request_messages = [
reqcmd.list_queues(),
reqcmd.create_queue(myfirstqueue),
reqcmd.list_queues(),
reqcmd.purge_queue(myfirstqueue),
reqcmd.list_queues(),
reqcmd.delete_queue(myfirstqueue),
reqcmd.list_exchanges(),
reqcmd.create_exchange(myfirstexchange),
reqcmd.list_exchanges(),
reqcmd.delete_exchange(myfirstexchange),
]
logger.debug("requests {0}".format(self.request_messages))
def on_start(self, event):
......
......@@ -26,7 +26,7 @@ class TestRequestQueue:
"name": queue,
"strict": True,
"properties": {"auto-delete": False,
"qpid.auto_delete_timeout": 10}}}
"qpid.auto_delete_timeout": 0}}}
logger.debug("Expected content -> {0}".format(expected_content))
expected_properties = {"x-amqp-0-10.app-id": "qmf2", "qmf.opcode": "_method_request", "method": "request"}
......@@ -72,3 +72,25 @@ class TestRequestQueue:
assert content == expected_content
assert properties == expected_properties
@pytest.mark.list
def test_purge_queue_myqueue(self):
req = RequestCmd()
queue = "myqueue"
content, properties = req.purge_queue(queue)
logger.debug("Content -> {0}".format(content))
logger.debug("Properties -> {0}".format(properties))
expected_content = {"_object_id": {"_object_name": "org.apache.qpid.broker:queue:{0}".format(queue)},
"_method_name": "purge",
"_arguments": {"type": "queue",
"name": queue,
"filter": dict()}}
logger.debug("Expected content -> {0}".format(expected_content))
expected_properties = {"x-amqp-0-10.app-id": "qmf2", "qmf.opcode": "_method_request", "method": "request"}
logger.debug("Expected properties -> {0}".format(expected_properties))
assert content == expected_content
assert properties == expected_properties
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment