~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to azure-sdk-for-python-master/tests/test_cloudstorageaccount.py

  • Committer: Curtis Hovey
  • Date: 2015-06-11 19:35:22 UTC
  • mto: This revision was merged to the branch mainline in revision 983.
  • Revision ID: curtis@canonical.com-20150611193522-o2nqkqb04o2i75wv
Remove euca_dump_logs because it has not been used this year.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#-------------------------------------------------------------------------
 
2
# Copyright (c) Microsoft.  All rights reserved.
 
3
#
 
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
 
8
#
 
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
#--------------------------------------------------------------------------
 
15
import unittest
 
16
 
 
17
from azure import WindowsAzureError
 
18
from azure.storage import (
 
19
    BlobService,
 
20
    CloudStorageAccount,
 
21
    QueueService,
 
22
    TableService,
 
23
    )
 
24
from util import (
 
25
    AzureTestCase,
 
26
    credentials,
 
27
    getUniqueName,
 
28
    )
 
29
 
 
30
#------------------------------------------------------------------------------
 
31
 
 
32
 
 
33
class CloudStorageAccountTest(AzureTestCase):
 
34
 
 
35
    def setUp(self):
 
36
        self.account = CloudStorageAccount(
 
37
            account_name=credentials.getStorageServicesName(),
 
38
            account_key=credentials.getStorageServicesKey())
 
39
 
 
40
    #--Test cases --------------------------------------------------------
 
41
    def test_create_blob_service(self):
 
42
        # Arrange
 
43
 
 
44
        # Act
 
45
        service = self.account.create_blob_service()
 
46
 
 
47
        # Assert
 
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())
 
54
 
 
55
    def test_create_blob_service_empty_credentials(self):
 
56
        # Arrange
 
57
 
 
58
        # Act
 
59
        bad_account = CloudStorageAccount('', '')
 
60
        with self.assertRaises(WindowsAzureError):
 
61
            service = bad_account.create_blob_service()
 
62
 
 
63
        # Assert
 
64
 
 
65
    def test_create_table_service(self):
 
66
        # Arrange
 
67
 
 
68
        # Act
 
69
        service = self.account.create_table_service()
 
70
 
 
71
        # Assert
 
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())
 
78
 
 
79
    def test_create_queue_service(self):
 
80
        # Arrange
 
81
 
 
82
        # Act
 
83
        service = self.account.create_queue_service()
 
84
 
 
85
        # Assert
 
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())
 
92
 
 
93
#------------------------------------------------------------------------------
 
94
if __name__ == '__main__':
 
95
    unittest.main()