-
Notifications
You must be signed in to change notification settings - Fork 2
Add initial VuMark generation API test #2931
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
d2b383a
Add minimal VuMark API interaction test
adamtheturtle a133585
Share VuMark credentials across secrets files
adamtheturtle 00a5951
Set VuMark test Accept header
adamtheturtle f8c083c
Make VuMark test assert successful generation
adamtheturtle 9efcf5e
Use VuMark fixture fields in generation test
adamtheturtle 18cedb6
Update CI workflow and remove VuMark test skip logic
adamtheturtle 6d87404
Generate VuMark instance IDs in test instead of env settings
adamtheturtle dfd0bde
Refactor secrets generation to initialize VuMark data once
adamtheturtle d65bccf
Fix typing in VuMark setup refactor
adamtheturtle a762e69
Remove redundant VuMark None check for pyright
adamtheturtle ee59318
Skip VuMark provisioning when no secrets files are missing
adamtheturtle 2ea8843
Merge origin/main into adamtheturtle/vumark-api-test
adamtheturtle 9409d2e
Merge origin/main into adamtheturtle/vumark-api-test
adamtheturtle 381878f
Merge remote-tracking branch 'origin/main' into adamtheturtle/vumark-…
adamtheturtle 79bad8d
Merge origin/main into adamtheturtle/vumark-api-test
adamtheturtle f706b1a
Reset VuMark secrets files to origin/main
adamtheturtle 7dcfeef
Add mock VuMark instance generation support and class-based test
adamtheturtle 9cd8765
Fix generator teardown pattern in backend fixture
adamtheturtle bf6ed8c
Merge remote-tracking branch 'origin/main' into adamtheturtle/vumark-…
adamtheturtle 43e2ac6
Add VuMark target setup to mock backends
adamtheturtle bf8224a
Fix BugBot issues for VuMark support
adamtheturtle fbae231
Fix mypy typing in target validator test
adamtheturtle 6dea443
Resolve pyright typing in validator test
adamtheturtle 941348f
Remove uncovered branches from generate_vumark_instance
adamtheturtle 5442a76
Use valid default target ID for VuMark database settings
adamtheturtle 270f9d9
Use valid target ID placeholder in vuforia_secrets.env.example
adamtheturtle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| """Tests for the VuMark generation web API.""" | ||
|
|
||
| import json | ||
| from http import HTTPMethod, HTTPStatus | ||
| from uuid import uuid4 | ||
|
|
||
| import requests | ||
| from vws_auth_tools import authorization_header, rfc_1123_date | ||
|
|
||
| from tests.mock_vws.fixtures.credentials import VuMarkVuforiaDatabase | ||
|
|
||
| _VWS_HOST = "https://vws.vuforia.com" | ||
| _PNG_SIGNATURE = b"\x89PNG\r\n\x1a\n" | ||
|
|
||
|
|
||
| def test_generate_instance_success( | ||
| vumark_vuforia_database: VuMarkVuforiaDatabase, | ||
| ) -> None: | ||
| """A VuMark instance can be generated with valid template settings.""" | ||
| request_path = f"/targets/{vumark_vuforia_database.target_id}/instances" | ||
| content_type = "application/json" | ||
| generated_instance_id = uuid4().hex | ||
| content = json.dumps(obj={"instance_id": generated_instance_id}).encode( | ||
| encoding="utf-8" | ||
| ) | ||
| date = rfc_1123_date() | ||
| authorization_string = authorization_header( | ||
| access_key=vumark_vuforia_database.server_access_key, | ||
| secret_key=vumark_vuforia_database.server_secret_key, | ||
| method=HTTPMethod.POST, | ||
| content=content, | ||
| content_type=content_type, | ||
| date=date, | ||
| request_path=request_path, | ||
| ) | ||
|
|
||
| response = requests.post( | ||
| url=_VWS_HOST + request_path, | ||
| headers={ | ||
| "Accept": "image/png", | ||
| "Authorization": authorization_string, | ||
| "Content-Length": str(object=len(content)), | ||
| "Content-Type": content_type, | ||
| "Date": date, | ||
| }, | ||
| data=content, | ||
| timeout=30, | ||
| ) | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| assert response.status_code == HTTPStatus.OK | ||
| assert response.headers["Content-Type"].split(sep=";")[0] == "image/png" | ||
| assert response.content.startswith(_PNG_SIGNATURE) | ||
| assert len(response.content) > len(_PNG_SIGNATURE) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.