test/api_stub/requests/storage/storageaccount.rb in fog-azure-rm-0.0.4 vs test/api_stub/requests/storage/storageaccount.rb in fog-azure-rm-0.0.5
- old
+ new
@@ -1,19 +1,22 @@
module ApiStub
module Requests
module Storage
+ # Mock class for Storage Requests
class StorageAccount
- def self.storage_account_request
- body = ' {
- "location": "west us",
- "properties":{
- "accountType": "Standard_LRS"
+ def self.storage_account_request(storage_mgmt_client)
+ storage_account_hash = {
+ 'id' => '/subscriptions/67f2116d-4ea2-4c6c-b20a-f92183dbe3cb/resourceGroups/fog_test_rg/providers/Microsoft.Storage/storageAccounts/fogtestsasecond',
+ 'name' => 'fog-test-storage-account',
+ 'location' => 'west us',
+ 'sku' =>
+ {
+ 'name' => 'Standard_LRS'
}
- }'
- result = MsRestAzure::AzureOperationResponse.new(MsRest::HttpOperationRequest.new('', '', ''), Faraday::Response.new)
- result.body = Azure::ARM::Storage::Models::StorageAccount.deserialize_object(JSON.load(body))
- result
+ }
+ storage_account_mapper = Azure::ARM::Storage::Models::StorageAccount.mapper
+ storage_mgmt_client.deserialize(storage_account_mapper, storage_account_hash, 'hash')
end
def self.create_storage_account
storage_acc_obj = Azure::ARM::Storage::Models::StorageAccount.new
storage_acc_obj.id = '1'
@@ -23,12 +26,22 @@
storage_acc_obj.tags = nil
storage_acc_obj.properties = nil
storage_acc_obj
end
- def self.list_storage_accounts_for_rg
+ def self.storage_account_arguments
{
+ resource_group: 'gateway-RG',
+ name: 'fog_test_storage_account',
+ sku_name: 'Standard',
+ location: 'West US',
+ replication: 'LRS'
+ }
+ end
+
+ def self.list_storage_accounts_for_rg(storage_mgmt_client)
+ list_storage_accounts_hash = {
'value' =>
[
{
'id' => '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}',
'name' => 'accountName1',
@@ -45,14 +58,16 @@
'creationTime' => '2016-05-18T07:24:40Z'
}
}
]
}
+ storage_account_list_mapper = Azure::ARM::Storage::Models::StorageAccountListResult.mapper
+ storage_mgmt_client.deserialize(storage_account_list_mapper, list_storage_accounts_hash, 'hash')
end
- def self.list_storage_accounts
- {
+ def self.list_storage_accounts(storage_mgmt_client)
+ list_storage_accounts_hash = {
'value' =>
[
{
'id' => '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}',
'name' => 'accountName1',
@@ -69,43 +84,41 @@
'creationTime' => '2016-05-18T07:24:40Z'
}
}
]
}
+ storage_account_list_mapper = Azure::ARM::Storage::Models::StorageAccountListResult.mapper
+ storage_mgmt_client.deserialize(storage_account_list_mapper, list_storage_accounts_hash, 'hash')
end
- def self.true_case_for_check_name_availability
- {
+ def self.true_case_for_check_name_availability(storage_mgmt_client)
+ check_name_availability_hash = {
'nameAvailable' => true,
'reason' => 'AccountNameInvalid|AlreadyExists',
'message' => 'error message'
}
+ storage_account_check_name_avaiablability_mapper = Azure::ARM::Storage::Models::CheckNameAvailabilityResult.mapper
+ storage_mgmt_client.deserialize(storage_account_check_name_avaiablability_mapper, check_name_availability_hash, 'hash')
end
- def self.false_case_for_check_name_availability
- {
+ def self.false_case_for_check_name_availability(storage_mgmt_client)
+ check_name_availability_hash = {
'nameAvailable' => false,
'reason' => 'AccountNameInvalid|AlreadyExists',
'message' => 'error message'
}
+ storage_account_check_name_avaiablability_mapper = Azure::ARM::Storage::Models::CheckNameAvailabilityResult.mapper
+ storage_mgmt_client.deserialize(storage_account_check_name_avaiablability_mapper, check_name_availability_hash, 'hash')
end
- def self.azure_operation_response(body)
- MsRestAzure::AzureOperationResponse.new(MsRest::HttpOperationRequest.new('', '', ''), Faraday::Response.new, Azure::ARM::Storage::Models::CheckNameAvailabilityResult.deserialize_object(body))
- end
-
- def self.response_storage_account_list(body)
- MsRestAzure::AzureOperationResponse.new(MsRest::HttpOperationRequest.new('', '', ''), Faraday::Response.new, Azure::ARM::Storage::Models::StorageAccountListResult.deserialize_object(body))
- end
-
def self.list_keys_response
- body = '{
- "key1": "key1 value",
- "key2": "key2 value"
- }'
- result = MsRestAzure::AzureOperationResponse.new(MsRest::HttpOperationRequest.new('', '', ''), Faraday::Response.new)
- result.body = Azure::ARM::Storage::Models::StorageAccountKeys.deserialize_object(JSON.load(body))
- result
+ key1 = Azure::ARM::Storage::Models::StorageAccountKey.new
+ key1.key_name = 'key1'
+ key1.value = 'sfhyuiafhhfids0943'
+ key1.permissions = 'Full'
+ storage_account_key_list = Azure::ARM::Storage::Models::StorageAccountListKeysResult.new
+ storage_account_key_list.keys = [key1]
+ storage_account_key_list
end
end
end
end
end