|
1 | 1 | """ |
2 | | -Edit a mobile test returns "OK" response |
| 2 | +Edit a Mobile test returns "OK" response |
3 | 3 | """ |
4 | 4 |
|
| 5 | +from os import environ |
5 | 6 | from datadog_api_client import ApiClient, Configuration |
6 | 7 | from datadog_api_client.v1.api.synthetics_api import SyntheticsApi |
7 | | -from datadog_api_client.v1.model.synthetics_check_type import SyntheticsCheckType |
8 | | -from datadog_api_client.v1.model.synthetics_config_variable import SyntheticsConfigVariable |
9 | | -from datadog_api_client.v1.model.synthetics_config_variable_type import SyntheticsConfigVariableType |
10 | | -from datadog_api_client.v1.model.synthetics_mobile_step import SyntheticsMobileStep |
11 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params import SyntheticsMobileStepParams |
12 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params_direction import SyntheticsMobileStepParamsDirection |
13 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params_element import SyntheticsMobileStepParamsElement |
14 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params_element_context_type import ( |
15 | | - SyntheticsMobileStepParamsElementContextType, |
16 | | -) |
17 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params_element_relative_position import ( |
18 | | - SyntheticsMobileStepParamsElementRelativePosition, |
19 | | -) |
20 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params_element_user_locator import ( |
21 | | - SyntheticsMobileStepParamsElementUserLocator, |
22 | | -) |
23 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params_element_user_locator_values_items import ( |
24 | | - SyntheticsMobileStepParamsElementUserLocatorValuesItems, |
25 | | -) |
26 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params_element_user_locator_values_items_type import ( |
27 | | - SyntheticsMobileStepParamsElementUserLocatorValuesItemsType, |
28 | | -) |
29 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params_positions_items import ( |
30 | | - SyntheticsMobileStepParamsPositionsItems, |
31 | | -) |
32 | | -from datadog_api_client.v1.model.synthetics_mobile_step_params_variable import SyntheticsMobileStepParamsVariable |
33 | | -from datadog_api_client.v1.model.synthetics_mobile_step_type import SyntheticsMobileStepType |
34 | 8 | from datadog_api_client.v1.model.synthetics_mobile_test import SyntheticsMobileTest |
35 | 9 | from datadog_api_client.v1.model.synthetics_mobile_test_config import SyntheticsMobileTestConfig |
36 | 10 | from datadog_api_client.v1.model.synthetics_mobile_test_options import SyntheticsMobileTestOptions |
|
41 | 15 | from datadog_api_client.v1.model.synthetics_mobile_tests_mobile_application_reference_type import ( |
42 | 16 | SyntheticsMobileTestsMobileApplicationReferenceType, |
43 | 17 | ) |
44 | | -from datadog_api_client.v1.model.synthetics_restricted_roles import SyntheticsRestrictedRoles |
45 | | -from datadog_api_client.v1.model.synthetics_test_ci_options import SyntheticsTestCiOptions |
46 | | -from datadog_api_client.v1.model.synthetics_test_execution_rule import SyntheticsTestExecutionRule |
47 | | -from datadog_api_client.v1.model.synthetics_test_options_monitor_options import SyntheticsTestOptionsMonitorOptions |
48 | | -from datadog_api_client.v1.model.synthetics_test_options_monitor_options_notification_preset_name import ( |
49 | | - SyntheticsTestOptionsMonitorOptionsNotificationPresetName, |
50 | | -) |
51 | | -from datadog_api_client.v1.model.synthetics_test_options_retry import SyntheticsTestOptionsRetry |
52 | | -from datadog_api_client.v1.model.synthetics_test_options_scheduling import SyntheticsTestOptionsScheduling |
53 | | -from datadog_api_client.v1.model.synthetics_test_options_scheduling_timeframe import ( |
54 | | - SyntheticsTestOptionsSchedulingTimeframe, |
55 | | -) |
56 | 18 | from datadog_api_client.v1.model.synthetics_test_pause_status import SyntheticsTestPauseStatus |
57 | | -from datadog_api_client.v1.model.synthetics_test_restriction_policy_binding import ( |
58 | | - SyntheticsTestRestrictionPolicyBinding, |
59 | | -) |
60 | | -from datadog_api_client.v1.model.synthetics_test_restriction_policy_binding_relation import ( |
61 | | - SyntheticsTestRestrictionPolicyBindingRelation, |
62 | | -) |
| 19 | + |
| 20 | +# there is a valid "synthetics_mobile_test" in the system |
| 21 | +SYNTHETICS_MOBILE_TEST_PUBLIC_ID = environ["SYNTHETICS_MOBILE_TEST_PUBLIC_ID"] |
63 | 22 |
|
64 | 23 | body = SyntheticsMobileTest( |
| 24 | + name="Example-Synthetic-updated", |
| 25 | + status=SyntheticsTestPauseStatus.PAUSED, |
| 26 | + type=SyntheticsMobileTestType.MOBILE, |
65 | 27 | config=SyntheticsMobileTestConfig( |
66 | | - variables=[ |
67 | | - SyntheticsConfigVariable( |
68 | | - name="VARIABLE_NAME", |
69 | | - secure=False, |
70 | | - type=SyntheticsConfigVariableType.TEXT, |
71 | | - ), |
72 | | - ], |
| 28 | + variables=[], |
73 | 29 | ), |
74 | | - device_ids=[ |
75 | | - "chrome.laptop_large", |
76 | | - ], |
77 | | - message="Notification message", |
78 | | - name="Example test name", |
| 30 | + message="", |
79 | 31 | options=SyntheticsMobileTestOptions( |
80 | | - bindings=[ |
81 | | - SyntheticsTestRestrictionPolicyBinding( |
82 | | - principals=[], |
83 | | - relation=SyntheticsTestRestrictionPolicyBindingRelation.EDITOR, |
84 | | - ), |
85 | | - ], |
86 | | - ci=SyntheticsTestCiOptions( |
87 | | - execution_rule=SyntheticsTestExecutionRule.BLOCKING, |
88 | | - ), |
89 | 32 | device_ids=[ |
90 | | - "synthetics:mobile:device:apple_ipad_10th_gen_2022_ios_16", |
| 33 | + "synthetics:mobile:device:iphone_15_ios_17", |
91 | 34 | ], |
92 | 35 | mobile_application=SyntheticsMobileTestsMobileApplication( |
93 | | - application_id="00000000-0000-0000-0000-aaaaaaaaaaaa", |
94 | | - reference_id="00000000-0000-0000-0000-aaaaaaaaaaab", |
95 | | - reference_type=SyntheticsMobileTestsMobileApplicationReferenceType.LATEST, |
| 36 | + application_id="ab0e0aed-536d-411a-9a99-5428c27d8f8e", |
| 37 | + reference_id="6115922a-5f5d-455e-bc7e-7955a57f3815", |
| 38 | + reference_type=SyntheticsMobileTestsMobileApplicationReferenceType.VERSION, |
96 | 39 | ), |
97 | | - monitor_options=SyntheticsTestOptionsMonitorOptions( |
98 | | - notification_preset_name=SyntheticsTestOptionsMonitorOptionsNotificationPresetName.SHOW_ALL, |
99 | | - ), |
100 | | - restricted_roles=SyntheticsRestrictedRoles( |
101 | | - [ |
102 | | - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", |
103 | | - ] |
104 | | - ), |
105 | | - retry=SyntheticsTestOptionsRetry(), |
106 | | - scheduling=SyntheticsTestOptionsScheduling( |
107 | | - timeframes=[ |
108 | | - SyntheticsTestOptionsSchedulingTimeframe( |
109 | | - day=1, |
110 | | - _from="07:00", |
111 | | - to="16:00", |
112 | | - ), |
113 | | - SyntheticsTestOptionsSchedulingTimeframe( |
114 | | - day=3, |
115 | | - _from="07:00", |
116 | | - to="16:00", |
117 | | - ), |
118 | | - ], |
119 | | - timezone="America/New_York", |
120 | | - ), |
121 | | - tick_every=300, |
| 40 | + tick_every=3600, |
122 | 41 | ), |
123 | | - status=SyntheticsTestPauseStatus.LIVE, |
124 | | - steps=[ |
125 | | - SyntheticsMobileStep( |
126 | | - name="", |
127 | | - params=SyntheticsMobileStepParams( |
128 | | - check=SyntheticsCheckType.EQUALS, |
129 | | - direction=SyntheticsMobileStepParamsDirection.UP, |
130 | | - element=SyntheticsMobileStepParamsElement( |
131 | | - context_type=SyntheticsMobileStepParamsElementContextType.NATIVE, |
132 | | - relative_position=SyntheticsMobileStepParamsElementRelativePosition(), |
133 | | - user_locator=SyntheticsMobileStepParamsElementUserLocator( |
134 | | - values=[ |
135 | | - SyntheticsMobileStepParamsElementUserLocatorValuesItems( |
136 | | - type=SyntheticsMobileStepParamsElementUserLocatorValuesItemsType.ACCESSIBILITY_ID, |
137 | | - ), |
138 | | - ], |
139 | | - ), |
140 | | - ), |
141 | | - positions=[ |
142 | | - SyntheticsMobileStepParamsPositionsItems(), |
143 | | - ], |
144 | | - variable=SyntheticsMobileStepParamsVariable( |
145 | | - example="", |
146 | | - name="VAR_NAME", |
147 | | - ), |
148 | | - ), |
149 | | - public_id="pub-lic-id0", |
150 | | - type=SyntheticsMobileStepType.ASSERTELEMENTCONTENT, |
151 | | - ), |
152 | | - ], |
153 | | - tags=[ |
154 | | - "env:production", |
155 | | - ], |
156 | | - type=SyntheticsMobileTestType.MOBILE, |
| 42 | + steps=[], |
157 | 43 | ) |
158 | 44 |
|
159 | 45 | configuration = Configuration() |
160 | 46 | with ApiClient(configuration) as api_client: |
161 | 47 | api_instance = SyntheticsApi(api_client) |
162 | | - response = api_instance.update_mobile_test(public_id="public_id", body=body) |
| 48 | + response = api_instance.update_mobile_test(public_id=SYNTHETICS_MOBILE_TEST_PUBLIC_ID, body=body) |
163 | 49 |
|
164 | 50 | print(response) |
0 commit comments