Back to index

rabbitmq-server  2.8.4
errors.py
Go to the documentation of this file.
00001 import unittest
00002 import stomp
00003 import base
00004 import time
00005 
00006 class TestErrors(base.BaseTest):
00007 
00008     def test_invalid_queue_destination(self):
00009         self.__test_invalid_destination("queue", "/bah/baz")
00010 
00011     def test_invalid_empty_queue_destination(self):
00012         self.__test_invalid_destination("queue", "")
00013 
00014     def test_invalid_topic_destination(self):
00015         self.__test_invalid_destination("topic", "/bah/baz")
00016 
00017     def test_invalid_empty_topic_destination(self):
00018         self.__test_invalid_destination("topic", "")
00019 
00020     def test_invalid_exchange_destination(self):
00021         self.__test_invalid_destination("exchange", "/bah/baz/boo")
00022 
00023     def test_invalid_empty_exchange_destination(self):
00024         self.__test_invalid_destination("exchange", "")
00025 
00026     def test_invalid_default_exchange_destination(self):
00027         self.__test_invalid_destination("exchange", "//foo")
00028 
00029     def test_unknown_destination(self):
00030         self.listener.reset()
00031         self.conn.send(destination="/something/interesting")
00032 
00033         self.assertTrue(self.listener.await())
00034         self.assertEquals(1, len(self.listener.errors))
00035 
00036         err = self.listener.errors[0]
00037         self.assertEquals("Unknown destination", err['headers']['message'])
00038 
00039     def test_send_missing_destination(self):
00040         self.__test_missing_destination("SEND")
00041 
00042     def test_send_missing_destination(self):
00043         self.__test_missing_destination("SUBSCRIBE")
00044 
00045     def __test_missing_destination(self, command):
00046         self.listener.reset()
00047         self.conn.send_frame(command)
00048 
00049         self.assertTrue(self.listener.await())
00050         self.assertEquals(1, len(self.listener.errors))
00051 
00052         err = self.listener.errors[0]
00053         self.assertEquals("Missing destination", err['headers']['message'])
00054 
00055     def __test_invalid_destination(self, dtype, content):
00056         self.listener.reset()
00057         self.conn.send(destination="/" + dtype + content)
00058 
00059         self.assertTrue(self.listener.await())
00060         self.assertEquals(1, len(self.listener.errors))
00061 
00062         err = self.listener.errors[0]
00063         self.assertEquals("Invalid destination", err['headers']['message'])
00064         self.assertEquals("'" + content + "' is not a valid " +
00065                               dtype + " destination\n",
00066                           err['message'])
00067