Exemple #1
0
    def test_010_insert_queue_hyphenated_queuename(self):
        """Insert queue with hyphen in name."""
        url = self.cfg.base_url + '/queues/hyphen-name'
        result = http.put(url, self.header)

        self.assertEqual(result.status_code, 201)

        http.delete(url, self.header)
Exemple #2
0
    def test_002_insert_queue_case_insensitive(self):
        """Insert Queue with same name, different case."""
        url = self.cfg.base_url + '/queues/QteStquEue'

        result = http.put(url, self.header)
        self.assertEqual(result.status_code, 201)

        http.delete(url, self.header)
Exemple #3
0
    def test_006_insert_queue_header_plaintext(self):
        """Insert Queue with 'Accept': 'plain/text'."""
        url = self.cfg.base_url + '/queues/plaintextheader'
        header = functionlib.plain_text_in_header()

        result = http.put(url, header)
        self.assertEqual(result.status_code, 406)

        http.delete(url, self.header)
Exemple #4
0
    def test_007_insert_queue_header_asterisk(self):
        """Insert Queue with 'Accept': '*/*'."""
        url = self.cfg.base_url + '/queues/asteriskinheader'
        header = functionlib.asterisk_in_header()

        result = http.put(url, header)
        self.assertEqual(result.status_code, 201)

        http.delete(url, self.header)
Exemple #5
0
    def test_003_insert_queue_empty_json(self):
        """Update Queue with empty json."""
        url = self.cfg.base_url + '/queues/emptyjson'
        doc = '{}'

        result = http.put(url, self.header, doc)
        self.assertEqual(result.status_code, 201)

        http.delete(url, self.header)
Exemple #6
0
    def test_002_queue_insert_case_insensitive(self):
        """Insert Queue with same name, different case."""
        url = self.cfg.base_url + '/queues/QteStquEue'
        doc = '{"queue": "Orange"}'

        result = http.put(url, self.header, doc)
        self.assertEqual(result.status_code, 201)

        result = http.get(url, self.header)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.json(), json.loads(doc))

        http.delete(url, self.header)
Exemple #7
0
    def test_010_queue_insert_header_asterisk(self):
        """Insert Queue with 'Accept': '*/*'."""
        url = self.cfg.base_url + '/queues/asteriskinheader'
        header = functionlib.asterisk_in_header()
        doc = '{"queue": "*/* in header"}'

        result = http.put(url, header, doc)
        self.assertEqual(result.status_code, 201)

        result = http.get(url, self.header)
        self.assertEqual(result.status_code, 200)

        http.delete(url, self.header)
Exemple #8
0
    def test_012_insert_queue_with_metadata(self):
        """Insert queue with a non-empty request body."""
        url = self.cfg.base_url + '/queues/hasmetadata'
        doc = '{"queue": "Has Metadata"}'
        result = http.put(url, self.header, doc)

        self.assertEqual(result.status_code, 201)

        url = self.cfg.base_url + '/queues/hasmetadata/metadata'
        result = http.get(url, self.header)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.json(), {})

        url = self.cfg.base_url + '/queues/hasmetadata'
        http.delete(url, self.header)
Exemple #9
0
    def test_008_message_delete_nonexisting(self):
        """Delete non-existing Messages."""
        url = self.cfg.base_url + '/queues/messagetestqueue/messages'   \
                                  '/non-existing'
        result = http.delete(url, self.header)

        self.assertEqual(result.status_code, 204)
Exemple #10
0
def release_claim(*claim_response):
    """Deletes claim & verifies the delete was successful.

    Extracts claim id from the POST response input & deletes the claim.
    If DELETE claim succeeds, verifies that a GET claim returns 404.
    :param *claim_response: [header, body] returned for post claim request.
    """
    test_result_flag = False

    headers = claim_response[0]
    location = headers['Location']
    url = functionlib.create_url_from_appender(location)
    header = functionlib.create_marconi_headers()

    release_response = http.delete(url, header)
    if release_response.status_code == 204:
        test_result_flag = functionlib.verify_delete(url, header)
    else:
        print 'Release Claim HTTP code:{}'.format(release_response.status_code)
        print release_response.headers
        print release_response.text
        assert test_result_flag, 'Release Claim Failed'

    if not test_result_flag:
        assert test_result_flag, 'Get claim after the release failed'
Exemple #11
0
    def test_001_insert_queue(self):
        """Create Queue."""
        url = self.cfg.base_url + '/queues/qtestqueue'

        result = http.put(url, self.header)
        self.assertEqual(result.status_code, 201)

        response_headers = set(result.headers.keys())
        self.assertIsSubset(self.headers_response_empty, response_headers)

        url = self.cfg.base_url + '/queues/qtestqueue/metadata'
        result = http.get(url, self.header)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.json(), {})

        http.delete(url, self.header)
Exemple #12
0
    def test_007_claim_expired(self):
        """Update, Get and Release Expired Claim."""
        #Test Setup - Post Claim.
        url = self.cfg.base_url + '/queues/claimtestqueue/claims'
        doc = '{"ttl": 1, "grace": 0}'

        result = http.post(url, self.header, doc)
        self.assertEqual(result.status_code, 201)

        time.sleep(2)

        #Extract claim location and construct the claim URL.
        location = result.headers['Location']
        url = self.cfg.base_server + location

        #Update Expired Claim.
        doc = '{"ttl": 300}'
        result = http.patch(url, self.header, doc)
        self.assertEqual(result.status_code, 404)

        #Get Expired Claim.
        result = http.get(url, self.header)
        self.assertEqual(result.status_code, 404)

        #Release Expired Claim.
        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 204)
Exemple #13
0
def delete_msg(*postresponse):
    """Post DELETE message & verifies that a subsequent GET returns 404.

    :param *postresponse: [headers, body] returned for post message request.
    """
    test_result_flag = False
    headers = str(postresponse[0])
    headers = headers.replace("'", '"')
    headers = json.loads(headers)
    location = headers['location']
    url = functionlib.create_url_from_appender(location)
    header = functionlib.create_marconi_headers()
    deletemsg = http.delete(url, header)
    if deletemsg.status_code == 204:
        test_result_flag = functionlib.verify_delete(url, header)
    else:
        print('DELETE message failed')
        print('URL')
        print(url)
        print('headers')
        print(header)
        print('Response Body')
        print(deletemsg.text)
        print('DELETE Code {}'.format(deletemsg.status_code))

    return test_result_flag
Exemple #14
0
    def test_014_queue_metadata_toplevel_underscore(self):
        """Insert Queue with underscore in toplevel field."""
        url = self.cfg.base_url + '/queues/toplevel'
        result = http.put(url, self.header)

        url = self.cfg.base_url + '/queues/toplevel/metadata'
        doc = '{"_queue": "Top Level field with _"}'

        result = http.put(url, self.header, doc)
        self.assertEqual(result.status_code, 204)

        result = http.get(url, self.header)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.json(), json.loads(doc))

        url = self.cfg.base_url + '/queues/toplevel'
        http.delete(url, self.header)
Exemple #15
0
    def test_005_insert_queue_missing_header(self):
        """Insert Queue with missing header field.

        Request has no Accept header.
        """
        header = functionlib.missing_header_fields()

        url = self.cfg.base_url + '/queues/missingheader'
        http.put(url, header)

        url = self.cfg.base_url + '/queues/missingheader/metadata'
        doc = '{"queue": "Missing Header"}'

        result = http.put(url, header, doc)
        self.assertEqual(result.status_code, 400)

        url = self.cfg.base_url + '/queues/missingheader'
        http.delete(url, self.header)
Exemple #16
0
    def test_999_delete_queue(self):
        """Delete Queue.

        Deletes Queue & performs GET to confirm 404.
        """
        url = self.cfg.base_url + '/queues/qtestqueue'

        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 204)
Exemple #17
0
    def test_019_queue_insert_metadata_invalidchar(self):
        """Update Queues with invalid char in metadata."""
        url = self.cfg.base_url + '/queues/qtestqueue/metadata'
        doc = '{"queue": "#$%^&Apple"}'
        result = http.put(url, self.header, doc)

        self.assertEqual(result.status_code, 204)

        url = self.cfg.base_url + '/queues/qtestqueue'
        result = http.delete(url, self.header)
Exemple #18
0
    def test_009_message_partial_delete(self):
        """Delete Messages will be partially successful."""
        doc = msgfnlib.get_message_body(messagecount=3)
        url = self.cfg.base_url + '/queues/messagetestqueue/messages'
        result = http.post(url, self.header, doc)

        self.assertEqual(result.status_code, 201)

        #Delete posted message
        location = result.headers['Location']
        url = self.cfg.base_server + location
        url += ',nonexisting'
        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 204)
Exemple #19
0
    def test_008_claim_expired_delete_message(self):
        """Get & Delete Message from an Expired Claim."""
        #Test Setup - Post Claim.
        url = self.cfg.base_url + '/queues/claimtestqueue/claims'
        doc = '{"ttl": 1, "grace": 0}'

        result = http.post(url, self.header, doc)
        self.assertEqual(result.status_code, 201)

        time.sleep(2)

        #Get Claim & Message Locations.
        claim_location = result.headers['Location']
        message_location = result.json()[0]['href']

        #Delete message with expired claim ID
        url = self.cfg.base_server + message_location
        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 403)

        #Delete Expired Claim.
        url = self.cfg.base_server + claim_location
        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 204)
Exemple #20
0
    def test_009_claim_release(self):
        """Release Claim."""
        url = self.cfg.base_url + '/queues/claimtestqueue/claims'
        doc = '{"ttl": 300, "grace": 100}'

        result = http.post(url, self.header, doc)
        self.assertEqual(result.status_code, 201)

        #Extract claim location and construct the claim URL.
        location = result.headers['Location']
        url = self.cfg.base_server + location

        #Release Claim.
        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 204)
Exemple #21
0
    def test_015_queue_insert_nonASCII_metadata(self):
        """Insert Queue with non ASCII name."""
        url = self.cfg.base_url + '/queues/nonASCIImetadata'
        result = http.put(url, self.header)

        url = self.cfg.base_url + '/queues/nonASCIImetadata/metadata'
        doc = '{"汉字": "non ASCII metadata"}'
        result = http.put(url, self.header, doc)

        self.assertEqual(result.status_code, 204)

        result = http.get(url, self.header)
        self.assertEqual(result.status_code, 200)

        url = self.cfg.base_url + '/queues/nonASCIImetadata'
        result = http.delete(url, self.header)
Exemple #22
0
    def test_006_message_delete(self):
        """Delete Message."""
        doc = msgfnlib.get_message_body(messagecount=1)
        url = self.cfg.base_url + '/queues/messagetestqueue/messages'
        result = http.post(url, self.header, doc)

        self.assertEqual(result.status_code, 201)

        #Delete posted message
        location = result.headers['location']
        url = self.cfg.base_server + location
        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 204)

        result = http.get(url, self.header)
        self.assertEqual(result.status_code, 404)
Exemple #23
0
    def test_006_message_delete(self):
        """Delete Message."""
        doc = msgfnlib.get_message_body(messagecount=1)
        url = self.cfg.base_url + '/queues/messagetestqueue/messages'
        result = http.post(url, self.header, doc)

        self.assertEqual(result.status_code, 201)

        #Delete posted message
        href = result.json()['resources'][0]
        url = self.cfg.base_server + href

        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 204)

        result = http.get(url, self.header)
        self.assertEqual(result.status_code, 404)
Exemple #24
0
    def test_008_claim_expired_delete_message(self):
        """Get & Delete Message from an Expired Claim."""
        #Test Setup - Post Claim.
        url = self.cfg.base_url + '/queues/claimtestqueue/claims'
        doc = '{"ttl": 1, "grace": 0}'

        result = http.post(url, self.header, doc)
        self.assertEqual(result.status_code, 200)

        time.sleep(2)

        #Create url, using message location from claim response.
        message_location = result.json()[0]['href']
        url = self.cfg.base_server + message_location

        #Delete message with expired claim ID
        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 403)
Exemple #25
0
def delete_claimed_msgs(*claim_response):
    """Deletes claimed messages.

    Verifies that the deletes were successful with a GET on the deleted msg.
    :param *claim_response: [header, body] returned for post claim request.
    """
    test_result_flag = False

    urllist = create_urllist_fromhref(*claim_response)
    header = functionlib.create_marconi_headers()

    for url in urllist:
        delete_response = http.delete(url, header)
        if delete_response.status_code == 204:
            test_result_flag = functionlib.verify_delete(url, header)
        else:
            print 'DELETE message with claim ID: {}'.format(url)
            print delete_response.status_code
            print delete_response.headers
            print delete_response.text
            print 'Delete Claimed Message Failed'

    return test_result_flag
Exemple #26
0
    def test_999_claim_teardown(self):
        """Delete Queue after Claim Tests."""
        url = self.cfg.base_url + '/queues/claimtestqueue'

        result = http.delete(url, self.header)
        self.assertEqual(result.status_code, 204)
Exemple #27
0
 def test_999_message_teardown(self):
     url = self.cfg.base_url + '/queues/messagetestqueue'
     http.delete(url, self.header)