Skip to content

Commit 9582f32

Browse files
committed
test(mongodb): record with SCW_TEST_MONGODB_INSTANCE_ID when PYTHON_UPDATE_CASSETTE=true; replay uses fixed id
1 parent 166060f commit 9582f32

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

scaleway/scaleway/mongodb/v1/tests/test_custom_api.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
from vcr_config import scw_vcr
8+
from vcr_config import PYTHON_UPDATE_CASSETTE
89
from tests.utils import initialize_client_test
910
from scaleway.mongodb.v1.custom_api import MongodbUtilsV1API
1011

@@ -18,13 +19,18 @@ def test_create_snapshot_with_naive_expires_at_vcr() -> None:
1819
Path(__file__).with_name("cassettes")
1920
/ "test_create_snapshot_with_naive_expires_at_vcr.cassette.yaml"
2021
)
21-
if not cassette.exists() and not os.getenv("PYTHON_UPDATE_CASSETTES"):
22-
pytest.skip("cassette not recorded yet; set PYTHON_UPDATE_CASSETTES=true to record")
22+
if not cassette.exists() and not os.getenv("PYTHON_UPDATE_CASSETTE"):
23+
pytest.skip("cassette not recorded yet; set PYTHON_UPDATE_CASSETTE=true to record")
2324
client = initialize_client_test()
2425
api = MongodbUtilsV1API(client, bypass_validation=True)
2526

26-
# Fixed value to match cassette; record once locally, then CI replays
27-
instance_id = "dd5cd838-525b-4395-b2ae-4dec3381ceaf"
27+
# During recording, require a real instance_id via env; during replay, use the fixed value matching the cassette
28+
if PYTHON_UPDATE_CASSETTE:
29+
instance_id = os.getenv("SCW_TEST_MONGODB_INSTANCE_ID")
30+
if not instance_id:
31+
pytest.skip("SCW_TEST_MONGODB_INSTANCE_ID not set while recording")
32+
else:
33+
instance_id = "00000000-0000-0000-0000-000000000000"
2834

2935
# Naive datetime should be handled as UTC by the utils API
3036
naive_dt = datetime.now().replace(tzinfo=None) + timedelta(days=1)

0 commit comments

Comments
 (0)