Skip to content

Commit 44fb583

Browse files
committed
tests: register cassette with auto-naming
1 parent dd10ef2 commit 44fb583

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python: ["3.9", "3.11", "3.13"]
14+
python: [ '3.10' ,'3.11', '3.12', '3.13' ]
1515
products:
1616
- account
1717
- applesilicon

scaleway/scaleway/vpc/tests/test_vpc_sdk.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import os
2-
31
import pytest
2+
43
from scaleway.vpc.v2 import VpcV2API
54
from scaleway_core.api import ScalewayException
65
from scaleway_core.client import Client
@@ -12,40 +11,40 @@
1211
created_pn_count = 5
1312
created_vpc_count = 1
1413

14+
1515
@pytest.fixture(scope="module")
16+
@scw_vcr.use_cassette
1617
def vpc_api():
17-
with scw_vcr.use_cassette("vpc_api.yaml"):
1818
client = Client.from_config_file_and_env()
1919
api = VpcV2API(client)
2020
return api, client.default_project_id, region
2121

2222

2323
@pytest.fixture(scope="module")
24+
@scw_vcr.use_cassette
2425
def vpc(vpc_api):
2526
api, project_id, region = vpc_api
26-
with scw_vcr.use_cassette("vpc_create_fixture_setup.yaml"):
27-
vpc = api.create_vpc(
28-
enable_routing=True,
29-
region=region,
30-
project_id=project_id,
31-
name=random_name("vpc-test-sdk-python"),
32-
)
27+
vpc = api.create_vpc(
28+
enable_routing=True,
29+
region=region,
30+
project_id=project_id,
31+
name=random_name("vpc-test-sdk-python"),
32+
)
3333
yield vpc
34-
with scw_vcr.use_cassette("vpc_delete_fixture_teardown.yaml"):
35-
api.delete_vpc(vpc_id=vpc.id, region=region)
34+
api.delete_vpc(vpc_id=vpc.id, region=region)
3635

3736

3837
@pytest.fixture
38+
@scw_vcr.use_cassette
3939
def private_networks_to_cleanup(vpc_api):
4040
api, _, _ = vpc_api
4141
items = []
4242
yield items
43-
with scw_vcr.use_cassette("private_networks_delete_cleanup_fixture.yaml"):
44-
for pn in items:
45-
api.delete_private_network(private_network_id=pn.id)
43+
for pn in items:
44+
api.delete_private_network(private_network_id=pn.id)
4645

4746

48-
@scw_vcr.use_cassette("test_vpc_delete.yaml")
47+
@scw_vcr.use_cassette
4948
def test_vpc_delete(vpc_api):
5049
api, project_id, region = vpc_api
5150
vpc = api.create_vpc(
@@ -64,15 +63,15 @@ def test_vpc_delete(vpc_api):
6463
api.get_vpc(vpc_id=vpc.id)
6564

6665

67-
@scw_vcr.use_cassette("test_vpc_list.yaml")
66+
@scw_vcr.use_cassette()
6867
def test_vpc_list(vpc_api):
6968
api, _, region = vpc_api
7069
vpcs = api.list_vp_cs(region=region)
7170
assert isinstance(vpcs.vpcs, list)
7271
assert vpcs.total_count >= created_vpc_count
7372

7473

75-
@scw_vcr.use_cassette("test_private_network_create.yaml")
74+
@scw_vcr.use_cassette()
7675
def test_private_network_create(vpc_api, vpc, private_networks_to_cleanup):
7776
api, project_id, _ = vpc_api
7877
for i in range(created_pn_count):
@@ -86,31 +85,31 @@ def test_private_network_create(vpc_api, vpc, private_networks_to_cleanup):
8685
assert pn.vpc_id == vpc.id
8786

8887

89-
@scw_vcr.use_cassette("test_private_network_list.yaml")
88+
@scw_vcr.use_cassette()
9089
def test_private_network_list(vpc_api):
9190
api, _, region = vpc_api
9291
networks = api.list_private_networks(region=region)
9392
assert isinstance(networks.private_networks, list)
9493
assert networks.total_count >= created_pn_count
9594

9695

97-
@scw_vcr.use_cassette("test_vpc_get.yaml")
96+
@scw_vcr.use_cassette()
9897
def test_vpc_get(vpc_api, vpc):
9998
api, _, region = vpc_api
10099
fetched = api.get_vpc(vpc_id=vpc.id, region=region)
101100
assert fetched is not None
102101
assert fetched.id == vpc.id
103102

104103

105-
@scw_vcr.use_cassette("test_vpc_update.yaml")
104+
@scw_vcr.use_cassette()
106105
def test_vpc_update(vpc_api, vpc):
107106
api, _, _ = vpc_api
108107
updated = api.update_vpc(vpc_id=vpc.id, tags=tags)
109108
assert updated.tags == tags
110109
assert updated.id == vpc.id
111110

112111

113-
@scw_vcr.use_cassette("test_vpc_list_all.yaml")
112+
@scw_vcr.use_cassette()
114113
def test_vpc_list_all(vpc_api):
115114
api, _, _ = vpc_api
116115
vpcs = api.list_vp_cs_all()

0 commit comments

Comments
 (0)