def test_sas_signed_identifier(self):
        # Arrange
        si = SignedIdentifier()
        si.id = 'testid'
        si.access_policy.start = '2011-10-11'
        si.access_policy.expiry = '2018-10-12'
        si.access_policy.permission = QueueSharedAccessPermissions.READ
        identifiers = SignedIdentifiers()
        identifiers.signed_identifiers.append(si)

        resp = self.qs.set_queue_acl(self.test_queues[0], identifiers)

        self.qs.put_message(self.test_queues[0], 'message1')

        token = self.qs.generate_shared_access_signature(
            self.test_queues[0],
            SharedAccessPolicy(signed_identifier=si.id),
        )

        # Act
        service = QueueService(credentials.getStorageServicesName(),
                               sas_token=token)
        set_service_options(service)
        result = service.peek_messages(self.test_queues[0])

        # Assert
        self.assertIsNotNone(result)
        self.assertEqual(1, len(result))
        message = result[0]
        self.assertIsNotNone(message)
        self.assertNotEqual('', message.message_id)
        self.assertEqual('message1', message.message_text)
    def setUp(self):
        self.ts = TableService(credentials.getStorageServicesName(),
                               credentials.getStorageServicesKey())
        set_service_options(self.ts)

        self.table_name = getUniqueName('uttable')
        self.additional_table_names = []
    def test_sas_update(self):
        # Arrange
        self.qs.put_message(self.test_queues[0], 'message1')
        token = self.qs.generate_shared_access_signature(
            self.test_queues[0],
            self._get_shared_access_policy(
                QueueSharedAccessPermissions.UPDATE),
        )
        result = self.qs.get_messages(self.test_queues[0])

        # Act
        service = QueueService(credentials.getStorageServicesName(),
                               sas_token=token)
        set_service_options(service)
        service.update_message(
            self.test_queues[0],
            result[0].message_id,
            'updatedmessage1',
            result[0].pop_receipt,
            visibilitytimeout=0,
        )

        # Assert
        result = self.qs.get_messages(self.test_queues[0])
        self.assertEqual('updatedmessage1', result[0].message_text)
    def test_sas_signed_identifier(self):
        # Arrange
        si = SignedIdentifier()
        si.id = "testid"
        si.access_policy.start = "2011-10-11"
        si.access_policy.expiry = "2018-10-12"
        si.access_policy.permission = QueueSharedAccessPermissions.READ
        identifiers = SignedIdentifiers()
        identifiers.signed_identifiers.append(si)

        resp = self.qs.set_queue_acl(self.test_queues[0], identifiers)

        self.qs.put_message(self.test_queues[0], "message1")

        token = self.qs.generate_shared_access_signature(
            self.test_queues[0], SharedAccessPolicy(signed_identifier=si.id)
        )

        # Act
        service = QueueService(credentials.getStorageServicesName(), sas_token=token)
        set_service_options(service)
        result = service.peek_messages(self.test_queues[0])

        # Assert
        self.assertIsNotNone(result)
        self.assertEqual(1, len(result))
        message = result[0]
        self.assertIsNotNone(message)
        self.assertNotEqual("", message.message_id)
        self.assertEqual("message1", message.message_text)
def main():
    service = BlobService(
        credentials.getStorageServicesName(),
        credentials.getStorageServicesKey(),
    )

    service.create_container(CONTAINER_NAME)

    process(service, LOCAL_BLOCK_BLOB_FILES, CONNECTION_COUNTS, is_page_blob=False)
    process(service, LOCAL_PAGE_BLOB_FILES, CONNECTION_COUNTS, is_page_blob=True)
    def test_create_queue_service(self):
        # Arrange

        # Act
        service = self.account.create_queue_service()

        # Assert
        self.assertIsNotNone(service)
        self.assertIsInstance(service, QueueService)
        self.assertEqual(service.account_name, credentials.getStorageServicesName())
        self.assertEqual(service.account_key, credentials.getStorageServicesKey())
    def setUp(self):
        self.tc = TableService(credentials.getStorageServicesName(), 
                               credentials.getStorageServicesKey())

        self.tc.set_proxy(credentials.getProxyHost(), 
                          credentials.getProxyPort(), 
                          credentials.getProxyUser(), 
                          credentials.getProxyPassword())

        __uid = getUniqueTestRunID()
        table_base_name = u'testtable%s' % (__uid)
        self.table_name = getUniqueNameBasedOnCurrentTime(table_base_name)     
        self.additional_table_names = []
    def setUp(self):
        self.qs = create_storage_service(
            QueueService, credentials.getStorageServicesName(), credentials.getStorageServicesKey()
        )

        self.test_queues = []
        self.creatable_queues = []
        for i in range(10):
            self.test_queues.append(getUniqueName(TEST_QUEUE_PREFIX + str(i)))
        for i in range(4):
            self.creatable_queues.append(getUniqueName("mycreatablequeue" + str(i)))
        for queue_name in self.test_queues:
            self.qs.create_queue(queue_name)
示例#9
0
    def test_create_queue_service(self):
        # Arrange

        # Act
        service = self.account.create_queue_service()

        # Assert
        self.assertIsNotNone(service)
        self.assertIsInstance(service, QueueService)
        self.assertEqual(service.account_name,
                         credentials.getStorageServicesName())
        self.assertEqual(service.account_key,
                         credentials.getStorageServicesKey())
示例#10
0
    def setUp(self):
        self.qs = QueueService(credentials.getStorageServicesName(),
                               credentials.getStorageServicesKey())
        set_service_options(self.qs)

        self.test_queues = []
        self.creatable_queues = []
        for i in range(10):
            self.test_queues.append(getUniqueName(TEST_QUEUE_PREFIX + str(i)))
        for i in range(4):
            self.creatable_queues.append(
                getUniqueName('mycreatablequeue' + str(i)))
        for queue_name in self.test_queues:
            self.qs.create_queue(queue_name)
    def test_sas_add(self):
        # Arrange
        token = self.qs.generate_shared_access_signature(
            self.test_queues[0], self._get_shared_access_policy(QueueSharedAccessPermissions.ADD)
        )

        # Act
        service = QueueService(credentials.getStorageServicesName(), sas_token=token)
        set_service_options(service)
        result = service.put_message(self.test_queues[0], "addedmessage")

        # Assert
        result = self.qs.get_messages(self.test_queues[0])
        self.assertEqual("addedmessage", result[0].message_text)
    def test_sas_add(self):
        # Arrange
        token = self.qs.generate_shared_access_signature(
            self.test_queues[0],
            self._get_shared_access_policy(QueueSharedAccessPermissions.ADD),
        )

        # Act
        service = QueueService(credentials.getStorageServicesName(),
                               sas_token=token)
        set_service_options(service)
        result = service.put_message(self.test_queues[0], 'addedmessage')

        # Assert
        result = self.qs.get_messages(self.test_queues[0])
        self.assertEqual('addedmessage', result[0].message_text)
def main():
    service = BlobService(
        credentials.getStorageServicesName(),
        credentials.getStorageServicesKey(),
    )

    service.create_container(CONTAINER_NAME)

    process(service,
            LOCAL_BLOCK_BLOB_FILES,
            CONNECTION_COUNTS,
            is_page_blob=False)
    process(service,
            LOCAL_PAGE_BLOB_FILES,
            CONNECTION_COUNTS,
            is_page_blob=True)
    def test_sas_update(self):
        # Arrange
        self.qs.put_message(self.test_queues[0], "message1")
        token = self.qs.generate_shared_access_signature(
            self.test_queues[0], self._get_shared_access_policy(QueueSharedAccessPermissions.UPDATE)
        )
        result = self.qs.get_messages(self.test_queues[0])

        # Act
        service = QueueService(credentials.getStorageServicesName(), sas_token=token)
        set_service_options(service)
        service.update_message(
            self.test_queues[0], result[0].message_id, "updatedmessage1", result[0].pop_receipt, visibilitytimeout=0
        )

        # Assert
        result = self.qs.get_messages(self.test_queues[0])
        self.assertEqual("updatedmessage1", result[0].message_text)
    def test_sas_process(self):
        # Arrange
        self.qs.put_message(self.test_queues[0], "message1")
        token = self.qs.generate_shared_access_signature(
            self.test_queues[0], self._get_shared_access_policy(QueueSharedAccessPermissions.PROCESS)
        )

        # Act
        service = QueueService(credentials.getStorageServicesName(), sas_token=token)
        set_service_options(service)
        result = service.get_messages(self.test_queues[0])

        # Assert
        self.assertIsNotNone(result)
        self.assertEqual(1, len(result))
        message = result[0]
        self.assertIsNotNone(message)
        self.assertNotEqual("", message.message_id)
        self.assertEqual("message1", message.message_text)
    def setUp(self):
        self.queue_client = QueueService(credentials.getStorageServicesName(), 
                                         credentials.getStorageServicesKey())

        self.queue_client.set_proxy(credentials.getProxyHost(),
                                    credentials.getProxyPort(),
                                    credentials.getProxyUser(), 
                                    credentials.getProxyPassword())

        __uid = getUniqueTestRunID()

        queue_base_name = u'%s' % (__uid)
        self.test_queues = []
        self.creatable_queues = []
        for i in range(10):
            self.test_queues.append(TEST_QUEUE_PREFIX + str(i) + getUniqueNameBasedOnCurrentTime(queue_base_name))
        for i in range(4):
            self.creatable_queues.append('mycreatablequeue' + str(i) + getUniqueNameBasedOnCurrentTime(queue_base_name))
        for queue_name in self.test_queues:
            self.queue_client.create_queue(queue_name)
    def test_sas_read(self):
        # Arrange
        self.qs.put_message(self.test_queues[0], 'message1')
        token = self.qs.generate_shared_access_signature(
            self.test_queues[0],
            self._get_shared_access_policy(QueueSharedAccessPermissions.READ),
        )

        # Act
        service = QueueService(credentials.getStorageServicesName(),
                               sas_token=token)
        set_service_options(service)
        result = service.peek_messages(self.test_queues[0])

        # Assert
        self.assertIsNotNone(result)
        self.assertEqual(1, len(result))
        message = result[0]
        self.assertIsNotNone(message)
        self.assertNotEqual('', message.message_id)
        self.assertEqual('message1', message.message_text)
 def setUp(self):
     self.account = CloudStorageAccount(
         account_name=credentials.getStorageServicesName(),
         account_key=credentials.getStorageServicesKey())
-------------------------------------------------
>>> queue_service.put_message('taskqueue', 'Hello World')
>>> messages = queue_service.get_messages('taskqueue', numofmessages=16, visibilitytimeout=5*60)
>>> for message in messages:
...     print(message.message_text)
...     queue_service.delete_message('taskqueue', message.message_id, message.pop_receipt)
Hello World Again
Hello World

How To: Get the Queue Length
----------------------------
>>> queue_metadata = queue_service.get_queue_metadata('taskqueue')
>>> count = queue_metadata['x-ms-approximate-messages-count']
>>> count
u'0'

How To: Delete a Queue
----------------------
>>> queue_service.delete_queue('taskqueue')
True

"""
from util import credentials

name = credentials.getStorageServicesName()
key = credentials.getStorageServicesKey()

if __name__ == "__main__":
    import doctest
    doctest.testmod()
示例#20
0
 def setUp(self):
     self.account = CloudStorageAccount(
         account_name=credentials.getStorageServicesName(),
         account_key=credentials.getStorageServicesKey())
示例#21
0
-------------------------------------------------
>>> queue_service.put_message('taskqueue', 'Hello World')
>>> messages = queue_service.get_messages('taskqueue', numofmessages=16, visibilitytimeout=5*60)
>>> for message in messages:
...     print(message.message_text)
...     queue_service.delete_message('taskqueue', message.message_id, message.pop_receipt)
Hello World Again
Hello World

How To: Get the Queue Length
----------------------------
>>> queue_metadata = queue_service.get_queue_metadata('taskqueue')
>>> count = queue_metadata['x-ms-approximate-messages-count']
>>> count
u'0'

How To: Delete a Queue
----------------------
>>> queue_service.delete_queue('taskqueue')
True

"""
from util import credentials

name = credentials.getStorageServicesName()
key = credentials.getStorageServicesKey()

if __name__ == "__main__":
    import doctest
    doctest.testmod()