Skip to content

Add VCR cassette re-recording tooling - #331

Merged
dmitry-mukhin merged 6 commits into
mainfrom
chore/add-vcr-rerecord
Sep 23, 2026
Merged

dmitry-mukhin merged 6 commits into
mainfrom
chore/add-vcr-rerecord

Conversation

@dmitry-mukhin

@dmitry-mukhin dmitry-mukhin commented Sep 21, 2026

Copy link
Copy Markdown
Member

Description

Add a script and makefile command to rebuild VCR cassettes.

@dmitry-mukhin
dmitry-mukhin added this pull request to stack #332 September 21, 2026 13:38
@dmitry-mukhin
dmitry-mukhin force-pushed the chore/add-vcr-rerecord branch 2 times, most recently from 11d02e0 to 02fc8c7 Compare September 21, 2026 20:11
Base automatically changed from fix/vcr-cassetes-and-query-rebuild to main September 22, 2026 11:45
Comment thread scripts/rerecord_cassettes.py
Comment thread scripts/rerecord_cassettes.py Outdated
Comment on lines +106 to +117
print("== Preparing fixtures and applying UUID substitutions ==")
if prepare_fixtures() != 0:
print("Fixture preparation failed; aborting.")
return 1

for module, cassette_dir, names in MODULES:
print(f"\n== Recording {module} ==")

# Reset the fixture's tags to baseline before each module.
if prepare_fixtures() != 0:
print("Fixture reset failed; aborting.")
return 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("== Preparing fixtures and applying UUID substitutions ==")
if prepare_fixtures() != 0:
print("Fixture preparation failed; aborting.")
return 1
for module, cassette_dir, names in MODULES:
print(f"\n== Recording {module} ==")
# Reset the fixture's tags to baseline before each module.
if prepare_fixtures() != 0:
print("Fixture reset failed; aborting.")
return 1
print("== Preparing fixtures and applying UUID substitutions ==")
for module, cassette_dir, names in MODULES:
print(f"\n== Recording {module} ==")
# Reset the fixture's tags to baseline before each module.
if prepare_fixtures() != 0:
print("Fixture reset failed; aborting.")
return 1

Comment thread scripts/prepare_vcr_fixtures.py
Comment thread scripts/rerecord_cassettes.py Outdated
Comment on lines +87 to +97
def run(cmd, env=None):
print(f"\n$ {' '.join(cmd)}", flush=True)
return subprocess.run(cmd, cwd=ROOT, env=env).returncode


def prepare_fixtures():
return run([sys.executable, str(PREPARE)])


def main():
pub_key = os.environ.get("UPLOADCARE_PUBLIC_KEY", "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's annotate this?

Comment thread scripts/vcr_fixtures.json Outdated
@@ -0,0 +1,11 @@
{
"pub_key": "27f2cfb68ead78acd3a5",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that's a public project key, but I guess it's not what exactly we want to store in our public library: Upload API is not protected, for this test project secure uploads disabled -> anybody can upload to this project.
Not critical, but it's potential vulnerability point.

I suggest to keep not a key, but fingerprint, and comparing hexed value:

uploadcare = Uploadcare(public_key=pub_key, secret_key=secret_key)
manifest = json.loads(MANIFEST.read_text()) if MANIFEST.exists() else {}
if manifest.get("pub_key", pub_key) != pub_key:
print(
f"Manifest was recorded against project "
f"{manifest['pub_key']!r}, but the environment points at "
f"{pub_key!r}. Refusing to mix projects."
)
return 1

{"album": "summer sunset"},
),
("no_tags", "no-tags.txt", True, None, None),
("sunset_2", "sunset-beach.jpg", False, ["cat"], None),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why storing is disabled?

{
"pub_key": "27f2cfb68ead78acd3a5",
"files": {
"main": "cdc00a7a-366f-4e0b-a942-9a7141b4004b",
"no_tags": "41a56ce7-48a4-486e-b8ed-4fd5f4051e08",
"sunset_2": "31c96931-65c8-4229-9c89-87f0e074a5c1",
"sunset_3": "82f88125-216e-4bd3-b84f-134c0de1d047",
"sunset_4": "cf05d23e-06c1-4a51-8357-7be85664aaf3",
"sunset_5": "6d8f0b99-3016-4460-a1f6-c890e03961fd"
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need this for the search tests.
files can be ephemeral, we onlyh need them to (re)create cassettes.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@dmitry-mukhin
dmitry-mukhin removed this pull request from stack #332 September 22, 2026 16:08
@dmitry-mukhin
dmitry-mukhin added this pull request to stack #337 September 22, 2026 16:10
@dmitry-mukhin
dmitry-mukhin merged commit 2c58b86 into main Sep 23, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants