-
-
Notifications
You must be signed in to change notification settings - Fork 271
Follow up of #689 - providing spool weight deltas as part of new payload_extras attribute in Spool Event #902
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
Open
chof747
wants to merge
17
commits into
Donkie:master
Choose a base branch
from
chof747:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4858418
updated package lock
chof747 7996b7f
added delta of spool usage weight to websocket event
chof747 680a867
merged upstream changes
chof747 1f3a5b3
Merge branch 'Donkie-master'
chof747 087011f
fixed linting issues
chof747 8ddf280
fixed issue with optional parameter
chof747 f9c3c36
Merge pull request #2 from Donkie/master
chof747 48d211c
change from spool delta from main payload to payload_extras
chof747 43ae901
added websocket test case for event triggering with payloud_extras
chof747 0a94947
renamed test_websocket to test_spool_event
chof747 d92e29e
Merge branch 'master' into master
chof747 f21f4e3
fixing linting issues
chof747 04acadc
Merge pull request #3 from chof747:bugfix/pr-902-ci-style
chof747 725575b
changed value type of payload_extra dict to Any to resolve review com…
chof747 19117da
Merge branch 'master' into master
chof747 e705696
models.py changed payload_extra value type to str
chof747 c18a582
removed import of Any
chof747 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| pytest==9.1.1 | ||
| pytest-asyncio==1.4.0 | ||
| httpx==0.27.0 | ||
| websockets==13.1 | ||
| websockets==15.0.1 |
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,51 @@ | ||
| """Integration tests for spool websocket events.""" | ||
|
|
||
| import asyncio | ||
| import json | ||
| from typing import Any | ||
|
|
||
| import httpx | ||
| import pytest | ||
| import websockets | ||
|
|
||
| from ..conftest import URL | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_use_weight_websocket_has_weight_delta(random_filament: dict[str, Any]): | ||
| """Test websocket payload extras for spool weight usage.""" | ||
| #Setup | ||
| result = httpx.post( | ||
| f"{URL}/api/v1/spool", | ||
| json={"filament_id": random_filament["id"], "remaining_weight": 1000}, | ||
| ) | ||
| result.raise_for_status() | ||
| spool = result.json() | ||
| spool_id = spool["id"] | ||
| ws_url = URL.replace("http://", "ws://").replace("https://", "wss://") + f"/api/v1/spool/{spool_id}" | ||
| use_weight = 6.9 | ||
|
|
||
| try: | ||
| async with websockets.connect(ws_url) as ws: | ||
| # keep the socket loop healthy before triggering update | ||
| await ws.send("ping") | ||
| check = json.loads(await asyncio.wait_for(ws.recv(), timeout=2)) | ||
| assert check["status"] == "healthy" | ||
|
|
||
| #execute | ||
| r = httpx.put(f"{URL}/api/v1/spool/{spool_id}/use", json={"use_weight": use_weight}) | ||
| r.raise_for_status() | ||
| raw = await asyncio.wait_for(ws.recv(), timeout=5) | ||
| evt = json.loads(raw) | ||
| #verify | ||
| assert evt["resource"] == "spool" | ||
| assert evt["type"] == "updated" | ||
| assert evt["payload"]["id"] == spool_id | ||
| assert evt["payload_extras"]["weight_delta"] == pytest.approx(use_weight) | ||
| assert "event_delta" not in evt["payload"].get("extra", {}) | ||
| #cleanup-ws | ||
| await ws.close(code=1000) | ||
| await asyncio.sleep(0.6) | ||
| finally: | ||
| #cleanup | ||
| httpx.delete(f"{URL}/api/v1/spool/{spool_id}").raise_for_status() |
Oops, something went wrong.
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.