Skip to content

Commit 88e145b

Browse files
chore: improve example values
1 parent 114a23b commit 88e145b

1 file changed

Lines changed: 180 additions & 36 deletions

File tree

tests/api_resources/test_page_rules.py

Lines changed: 180 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@ class TestPageRules:
2626
def test_method_create(self, client: Cloudflare) -> None:
2727
page_rule = client.page_rules.create(
2828
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
29-
actions=[{}],
30-
targets=[{}],
29+
actions=[{"id": "browser_check"}],
30+
targets=[
31+
{
32+
"constraint": {
33+
"operator": "matches",
34+
"value": "*example.com/images/*",
35+
},
36+
"target": "url",
37+
}
38+
],
3139
)
3240
assert_matches_type(Optional[PageRule], page_rule, path=["response"])
3341

@@ -61,8 +69,16 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
6169
def test_raw_response_create(self, client: Cloudflare) -> None:
6270
response = client.page_rules.with_raw_response.create(
6371
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
64-
actions=[{}],
65-
targets=[{}],
72+
actions=[{"id": "browser_check"}],
73+
targets=[
74+
{
75+
"constraint": {
76+
"operator": "matches",
77+
"value": "*example.com/images/*",
78+
},
79+
"target": "url",
80+
}
81+
],
6682
)
6783

6884
assert response.is_closed is True
@@ -75,8 +91,16 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
7591
def test_streaming_response_create(self, client: Cloudflare) -> None:
7692
with client.page_rules.with_streaming_response.create(
7793
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
78-
actions=[{}],
79-
targets=[{}],
94+
actions=[{"id": "browser_check"}],
95+
targets=[
96+
{
97+
"constraint": {
98+
"operator": "matches",
99+
"value": "*example.com/images/*",
100+
},
101+
"target": "url",
102+
}
103+
],
80104
) as response:
81105
assert not response.is_closed
82106
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -92,8 +116,16 @@ def test_path_params_create(self, client: Cloudflare) -> None:
92116
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
93117
client.page_rules.with_raw_response.create(
94118
zone_id="",
95-
actions=[{}],
96-
targets=[{}],
119+
actions=[{"id": "browser_check"}],
120+
targets=[
121+
{
122+
"constraint": {
123+
"operator": "matches",
124+
"value": "*example.com/images/*",
125+
},
126+
"target": "url",
127+
}
128+
],
97129
)
98130

99131
@pytest.mark.skip(reason="generated params are incorrect")
@@ -102,8 +134,16 @@ def test_method_update(self, client: Cloudflare) -> None:
102134
page_rule = client.page_rules.update(
103135
pagerule_id="023e105f4ecef8ad9ca31a8372d0c353",
104136
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
105-
actions=[{}],
106-
targets=[{}],
137+
actions=[{"id": "browser_check"}],
138+
targets=[
139+
{
140+
"constraint": {
141+
"operator": "matches",
142+
"value": "*example.com/images/*",
143+
},
144+
"target": "url",
145+
}
146+
],
107147
)
108148
assert_matches_type(Optional[PageRule], page_rule, path=["response"])
109149

@@ -139,8 +179,16 @@ def test_raw_response_update(self, client: Cloudflare) -> None:
139179
response = client.page_rules.with_raw_response.update(
140180
pagerule_id="023e105f4ecef8ad9ca31a8372d0c353",
141181
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
142-
actions=[{}],
143-
targets=[{}],
182+
actions=[{"id": "browser_check"}],
183+
targets=[
184+
{
185+
"constraint": {
186+
"operator": "matches",
187+
"value": "*example.com/images/*",
188+
},
189+
"target": "url",
190+
}
191+
],
144192
)
145193

146194
assert response.is_closed is True
@@ -154,8 +202,16 @@ def test_streaming_response_update(self, client: Cloudflare) -> None:
154202
with client.page_rules.with_streaming_response.update(
155203
pagerule_id="023e105f4ecef8ad9ca31a8372d0c353",
156204
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
157-
actions=[{}],
158-
targets=[{}],
205+
actions=[{"id": "browser_check"}],
206+
targets=[
207+
{
208+
"constraint": {
209+
"operator": "matches",
210+
"value": "*example.com/images/*",
211+
},
212+
"target": "url",
213+
}
214+
],
159215
) as response:
160216
assert not response.is_closed
161217
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -172,16 +228,32 @@ def test_path_params_update(self, client: Cloudflare) -> None:
172228
client.page_rules.with_raw_response.update(
173229
pagerule_id="023e105f4ecef8ad9ca31a8372d0c353",
174230
zone_id="",
175-
actions=[{}],
176-
targets=[{}],
231+
actions=[{"id": "browser_check"}],
232+
targets=[
233+
{
234+
"constraint": {
235+
"operator": "matches",
236+
"value": "*example.com/images/*",
237+
},
238+
"target": "url",
239+
}
240+
],
177241
)
178242

179243
with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"):
180244
client.page_rules.with_raw_response.update(
181245
pagerule_id="",
182246
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
183-
actions=[{}],
184-
targets=[{}],
247+
actions=[{"id": "browser_check"}],
248+
targets=[
249+
{
250+
"constraint": {
251+
"operator": "matches",
252+
"value": "*example.com/images/*",
253+
},
254+
"target": "url",
255+
}
256+
],
185257
)
186258

187259
@parametrize
@@ -413,8 +485,16 @@ class TestAsyncPageRules:
413485
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
414486
page_rule = await async_client.page_rules.create(
415487
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
416-
actions=[{}],
417-
targets=[{}],
488+
actions=[{"id": "browser_check"}],
489+
targets=[
490+
{
491+
"constraint": {
492+
"operator": "matches",
493+
"value": "*example.com/images/*",
494+
},
495+
"target": "url",
496+
}
497+
],
418498
)
419499
assert_matches_type(Optional[PageRule], page_rule, path=["response"])
420500

@@ -448,8 +528,16 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
448528
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
449529
response = await async_client.page_rules.with_raw_response.create(
450530
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
451-
actions=[{}],
452-
targets=[{}],
531+
actions=[{"id": "browser_check"}],
532+
targets=[
533+
{
534+
"constraint": {
535+
"operator": "matches",
536+
"value": "*example.com/images/*",
537+
},
538+
"target": "url",
539+
}
540+
],
453541
)
454542

455543
assert response.is_closed is True
@@ -462,8 +550,16 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
462550
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
463551
async with async_client.page_rules.with_streaming_response.create(
464552
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
465-
actions=[{}],
466-
targets=[{}],
553+
actions=[{"id": "browser_check"}],
554+
targets=[
555+
{
556+
"constraint": {
557+
"operator": "matches",
558+
"value": "*example.com/images/*",
559+
},
560+
"target": "url",
561+
}
562+
],
467563
) as response:
468564
assert not response.is_closed
469565
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -479,8 +575,16 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
479575
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
480576
await async_client.page_rules.with_raw_response.create(
481577
zone_id="",
482-
actions=[{}],
483-
targets=[{}],
578+
actions=[{"id": "browser_check"}],
579+
targets=[
580+
{
581+
"constraint": {
582+
"operator": "matches",
583+
"value": "*example.com/images/*",
584+
},
585+
"target": "url",
586+
}
587+
],
484588
)
485589

486590
@pytest.mark.skip(reason="generated params are incorrect")
@@ -489,8 +593,16 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
489593
page_rule = await async_client.page_rules.update(
490594
pagerule_id="023e105f4ecef8ad9ca31a8372d0c353",
491595
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
492-
actions=[{}],
493-
targets=[{}],
596+
actions=[{"id": "browser_check"}],
597+
targets=[
598+
{
599+
"constraint": {
600+
"operator": "matches",
601+
"value": "*example.com/images/*",
602+
},
603+
"target": "url",
604+
}
605+
],
494606
)
495607
assert_matches_type(Optional[PageRule], page_rule, path=["response"])
496608

@@ -526,8 +638,16 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
526638
response = await async_client.page_rules.with_raw_response.update(
527639
pagerule_id="023e105f4ecef8ad9ca31a8372d0c353",
528640
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
529-
actions=[{}],
530-
targets=[{}],
641+
actions=[{"id": "browser_check"}],
642+
targets=[
643+
{
644+
"constraint": {
645+
"operator": "matches",
646+
"value": "*example.com/images/*",
647+
},
648+
"target": "url",
649+
}
650+
],
531651
)
532652

533653
assert response.is_closed is True
@@ -541,8 +661,16 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) ->
541661
async with async_client.page_rules.with_streaming_response.update(
542662
pagerule_id="023e105f4ecef8ad9ca31a8372d0c353",
543663
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
544-
actions=[{}],
545-
targets=[{}],
664+
actions=[{"id": "browser_check"}],
665+
targets=[
666+
{
667+
"constraint": {
668+
"operator": "matches",
669+
"value": "*example.com/images/*",
670+
},
671+
"target": "url",
672+
}
673+
],
546674
) as response:
547675
assert not response.is_closed
548676
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -559,16 +687,32 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
559687
await async_client.page_rules.with_raw_response.update(
560688
pagerule_id="023e105f4ecef8ad9ca31a8372d0c353",
561689
zone_id="",
562-
actions=[{}],
563-
targets=[{}],
690+
actions=[{"id": "browser_check"}],
691+
targets=[
692+
{
693+
"constraint": {
694+
"operator": "matches",
695+
"value": "*example.com/images/*",
696+
},
697+
"target": "url",
698+
}
699+
],
564700
)
565701

566702
with pytest.raises(ValueError, match=r"Expected a non-empty value for `pagerule_id` but received ''"):
567703
await async_client.page_rules.with_raw_response.update(
568704
pagerule_id="",
569705
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
570-
actions=[{}],
571-
targets=[{}],
706+
actions=[{"id": "browser_check"}],
707+
targets=[
708+
{
709+
"constraint": {
710+
"operator": "matches",
711+
"value": "*example.com/images/*",
712+
},
713+
"target": "url",
714+
}
715+
],
572716
)
573717

574718
@parametrize

0 commit comments

Comments
 (0)