1
#-------------------------------------------------------------------------
2
# Copyright (c) Microsoft. All rights reserved.
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
#--------------------------------------------------------------------------
17
from azure import WindowsAzureError
18
from azure.storage import (
30
#------------------------------------------------------------------------------
33
class CloudStorageAccountTest(AzureTestCase):
36
self.account = CloudStorageAccount(
37
account_name=credentials.getStorageServicesName(),
38
account_key=credentials.getStorageServicesKey())
40
#--Test cases --------------------------------------------------------
41
def test_create_blob_service(self):
45
service = self.account.create_blob_service()
48
self.assertIsNotNone(service)
49
self.assertIsInstance(service, BlobService)
50
self.assertEqual(service.account_name,
51
credentials.getStorageServicesName())
52
self.assertEqual(service.account_key,
53
credentials.getStorageServicesKey())
55
def test_create_blob_service_empty_credentials(self):
59
bad_account = CloudStorageAccount('', '')
60
with self.assertRaises(WindowsAzureError):
61
service = bad_account.create_blob_service()
65
def test_create_table_service(self):
69
service = self.account.create_table_service()
72
self.assertIsNotNone(service)
73
self.assertIsInstance(service, TableService)
74
self.assertEqual(service.account_name,
75
credentials.getStorageServicesName())
76
self.assertEqual(service.account_key,
77
credentials.getStorageServicesKey())
79
def test_create_queue_service(self):
83
service = self.account.create_queue_service()
86
self.assertIsNotNone(service)
87
self.assertIsInstance(service, QueueService)
88
self.assertEqual(service.account_name,
89
credentials.getStorageServicesName())
90
self.assertEqual(service.account_key,
91
credentials.getStorageServicesKey())
93
#------------------------------------------------------------------------------
94
if __name__ == '__main__':