-
Notifications
You must be signed in to change notification settings - Fork 1
🧪 [testing improvement] Add KeyError test for har2img #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
dacefae
1ac8bc2
6809933
cef17bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ master ] | ||
| pull_request: | ||
| branches: [ master ] | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v3 | ||
| with: | ||
| enable-cache: true | ||
| - name: Run Ruff | ||
| run: uv run --project stapler-scripts ruff check stapler-scripts/ | ||
|
|
||
| test-har2img: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v3 | ||
| with: | ||
| enable-cache: true | ||
| - name: Run har2img tests | ||
| run: | | ||
| export PYTHONPATH=$PYTHONPATH:$(pwd)/stapler-scripts | ||
| uv run --project stapler-scripts pytest stapler-scripts/test_har2img.py | ||
|
|
||
| test-display-switch: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v3 | ||
| with: | ||
| enable-cache: true | ||
| - name: Run display-switch tests | ||
| run: | | ||
| cd stapler-scripts/display-switch | ||
| uv run pytest | ||
|
|
||
| test-ark-mod-manager: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v3 | ||
| with: | ||
| enable-cache: true | ||
| - name: Run ark-mod-manager tests | ||
| run: | | ||
| cd stapler-scripts/ark-mod-manager | ||
| uv run pytest | ||
|
|
||
| test-claude-proxy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v3 | ||
| with: | ||
| enable-cache: true | ||
| - name: Run claude-proxy tests | ||
| run: | | ||
| cd stapler-scripts/claude-proxy | ||
| uv run python -m pytest test_providers.py | ||
|
|
||
| bazel-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Bazel | ||
| uses: bazelbuild/setup-bazel@v2 | ||
| with: | ||
| bazelrc: | | ||
| common --color=yes | ||
| - name: Run Bazel Tests | ||
| run: bazel test //stapler-scripts/... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Empty build file for the root |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| workspace(name = "stapler_scripts_repo") | ||
|
|
||
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
|
||
| # Rules Python for Python support in Bazel | ||
| http_archive( | ||
| name = "rules_python", | ||
| sha256 = "6f0b4070a25b774f2ec18683e336e4f3a73c17822986423c8a98d363717208d1", | ||
| strip_prefix = "rules_python-0.31.0", | ||
| url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.0.tar.gz", | ||
| ) | ||
|
|
||
| load("@rules_python//python:repositories.bzl", "py_repositories") | ||
| py_repositories() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") | ||
|
|
||
| py_library( | ||
| name = "har2img_lib", | ||
| srcs = ["har2img.py"], | ||
| visibility = ["//visibility:public"], | ||
| ) | ||
|
|
||
| py_binary( | ||
| name = "har2img", | ||
| srcs = ["har2img.py"], | ||
| main = "har2img.py", | ||
| deps = [":har2img_lib"], | ||
| ) | ||
|
|
||
| py_test( | ||
| name = "test_har2img", | ||
| srcs = ["test_har2img.py"], | ||
| deps = [ | ||
| ":har2img_lib", | ||
| ], | ||
| main = "test_har2img.py", | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [project] | ||
| name = "stapler-scripts" | ||
| version = "0.1.0" | ||
| description = "A collection of utility scripts for managing stapler services." | ||
| readme = "README.md" | ||
| requires-python = ">=3.12" | ||
| dependencies = [] | ||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "pytest>=9.0.2", | ||
| "ruff>=0.4.0", | ||
| ] |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,149 @@ | ||||||||||||
| import os | ||||||||||||
| import json | ||||||||||||
| import base64 | ||||||||||||
| import pytest | ||||||||||||
|
Comment on lines
+1
to
+4
|
||||||||||||
| import os | |
| import json | |
| import base64 | |
| import pytest | |
| import base64 |
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These assertions lock in an odd output naming convention (test.png.png). If the URL already ends with an image extension, appending another extension based on MIME type is likely unintended; it also makes output harder to predict. Consider adjusting har2img.py to avoid double extensions (and update this expectation accordingly).
| output_file = output_dir / "test.png.png" | |
| assert output_file.exists() | |
| output_files = list(output_dir.iterdir()) | |
| assert len(output_files) == 1 | |
| output_file = output_files[0] |
Copilot
AI
Apr 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same double-extension expectation here (valid.png.png). If you update the production code to avoid adding an extra extension when the URL already has one, this assertion should be updated to the intended filename.
| assert (output_dir / "valid.png.png").exists() | |
| assert not (output_dir / "invalid.png.png").exists() | |
| assert (output_dir / "valid.png").exists() | |
| assert not (output_dir / "invalid.png").exists() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process_har()assumesfolderalready exists. Since this is now a standalone function (and is called directly by tests/other potential callers), consider creating the directory insideprocess_har(or explicitly validating and raising) so callers don’t silently get per-file write errors when a non-existent output folder is passed in.