1
+ from azure .mgmt .automation import AutomationClient
2
+ from devtools_testutils import AzureMgmtRecordedTestCase , RandomNameResourceGroupPreparer , recorded_by_proxy
3
+
4
+ AZURE_LOCATION = "eastus"
5
+
6
+ class TestMgmtRunbook (AzureMgmtRecordedTestCase ):
7
+ def setup_method (self , method ):
8
+ self .mgmt_client = self .create_mgmt_client (AutomationClient )
9
+
10
+ def create_automation_account (self , group_name , location , account_name ):
11
+ automation_account_creation = self .mgmt_client .automation_account .create_or_update (
12
+ group_name , account_name , {"location" : location , "name" : account_name , "properties" : {"sku" : {"name" : "Free" }}}
13
+ )
14
+ return automation_account_creation .name
15
+
16
+ def create_runbook (self , group_name , location , account_name , runbook_name ):
17
+ runbook_creation = self .mgmt_client .runbook .create_or_update (
18
+ group_name , account_name , runbook_name , {"location" : location , "name" : runbook_name , "properties" : {"publishContentLink" : {"uri" : "https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.automation/101-automation/scripts/AzureAutomationTutorial.ps1" },"runbookType" : "PowerShell" }}
19
+ )
20
+ return runbook_creation .name
21
+
22
+ @RandomNameResourceGroupPreparer (location = AZURE_LOCATION )
23
+ @recorded_by_proxy
24
+ def test_get_runbook_content (self , resource_group ):
25
+ ACCOUNT_NAME = self .get_resource_name ("automationtest07" )
26
+ RUNBOOK_NAME = self .get_resource_name ("runbooktest07" )
27
+
28
+ account_name = self .create_automation_account (resource_group .name , AZURE_LOCATION , ACCOUNT_NAME )
29
+ runbook_name = self .create_runbook (resource_group .name , AZURE_LOCATION , account_name , RUNBOOK_NAME )
30
+
31
+ result = self .mgmt_client .runbook .get_content (resource_group .name , account_name , runbook_name )
0 commit comments