def setUp(self): super(TestMessages, self).setUp() self.queue_url = self.cfg.base_url + '/queues/{}'.format(uuid.uuid1()) http.put(self.queue_url, self.header) self.message_url = self.queue_url + '/messages'
def setUp(self): super(TestQueueMetaData, self).setUp() self.queue_url = self.cfg.base_url + '/queues/{}'.format(uuid.uuid1()) http.put(self.queue_url, self.header) self.queue_metadata_url = self.queue_url + '/metadata'
def test_check_queue_exists(self): """Checks if queue exists.""" url = self.cfg.base_url + '/queues/testqueue' http.put(url, self.header) result = http.get(url, self.header) self.assertEqual(result.status_code, 204) result = http.head(url, self.header) self.assertEqual(result.status_code, 204)
def setUp(self): super(TestClaims, self).setUp() self.queue_url = self.cfg.base_url + '/queues/{}'.format(uuid.uuid1()) http.put(self.queue_url, self.header) self.claim_url = self.queue_url + '/claims' #Post Messages url = self.queue_url + '/messages' doc = helpers.get_message_body(messagecount= self.cfg.message_paging_uplimit) for i in range(25): http.post(url, self.header, doc)
def setUpClass(cls): cls.cfg = config.Config() cls.header = helpers.create_marconi_headers() cls.headers_response_empty = set(['location']) cls.headers_response_with_body = set(['content-location', 'content-type']) cls.queue_url = cls.cfg.base_url + '/queues/{}'.format(uuid.uuid1()) http.put(cls.queue_url, cls.header) url = cls.queue_url + '/metadata' metadata = {"queue_metadata": "TEST METADATA"} http.put(url, cls.header, json.dumps(metadata))
def setUp(self): super(TestClaims, self).setUp() self.queue_url = self.cfg.base_url + '/queues/{}'.format(uuid.uuid1()) http.put(self.queue_url, self.header) self.claim_url = self.queue_url + '/claims' #Post Messages url = self.queue_url + '/messages' doc = helpers.get_message_body( messagecount=self.cfg.message_paging_uplimit) for i in range(25): http.post(url, self.header, doc)
def test_insert_queue_header_asterisk(self): """Insert Queue with 'Accept': '*/*'.""" self.url = self.cfg.base_url + '/queues/asteriskinheader' header = copy.copy(self.header) header["Accept"] = '*/*' result = http.put(self.url, header) self.assertEqual(result.status_code, 201)
def test_insert_queue_header_plaintext(self): """Insert Queue with 'Accept': 'plain/text'.""" self.url = self.cfg.base_url + '/queues/plaintextheader' header = copy.copy(self.header) header["Accept"] = 'plain/text' result = http.put(self.url, header) self.assertEqual(result.status_code, 406)
def test_insert_queue_invalid_authtoken(self): """Insert Queue with invalid authtoken.""" self.url = self.cfg.base_url + '/queues/invalidauthtoken' header = copy.copy(self.header) header["X-Auth-Token"] = 'invalid' result = http.put(self.url, header) self.assertEqual(result.status_code, 401)
def test_insert_queue_metadata(self, doc): """Insert Queue with empty json.""" result = http.put(self.queue_metadata_url, self.header, json.dumps(doc)) self.assertEqual(result.status_code, 204) result = http.get(self.queue_metadata_url, self.header) self.assertEqual(result.status_code, 200) self.assertEqual(result.json(), doc)
def test_insert_queue_invalid_name(self, queue_name): """Create Queue.""" self.url = self.cfg.base_url + '/queues/' + queue_name result = http.put(self.url, self.header) self.assertEqual(result.status_code, 400) self.url = self.url + '/metadata' result = http.get(self.url, self.header) self.assertEqual(result.status_code, 404)
def test_insert_queue_with_metadata(self): """Insert queue with a non-empty request body.""" self.url = self.cfg.base_url + '/queues/hasmetadata' doc = '{"queue": "Has Metadata"}' result = http.put(self.url, self.header, doc) self.assertEqual(result.status_code, 201) self.url = self.cfg.base_url + '/queues/hasmetadata/metadata' result = http.get(self.url, self.header) self.assertEqual(result.status_code, 200) self.assertEqual(result.json(), {})
def test_insert_queue(self, queue_name): """Create Queue.""" self.url = self.cfg.base_url + '/queues/' + queue_name result = http.put(self.url, self.header) self.assertEqual(result.status_code, 201) response_headers = set(result.headers.keys()) self.assertIsSubset(self.headers_response_empty, response_headers) self.url = self.url + '/metadata' result = http.get(self.url, self.header) self.assertEqual(result.status_code, 200) self.assertEqual(result.json(), {})
def test_insert_queue_invalid_metadata(self, doc): """Insert invalid metadata.""" result = http.put(self.queue_metadata_url, self.header, str(doc)) self.assertEqual(result.status_code, 400)