forked from got-feedBack/feedBack
-
Notifications
You must be signed in to change notification settings - Fork 0
Add regression for failed sloppak websocket load #17
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
carochacs
wants to merge
4
commits into
main
Choose a base branch
from
fix/sloppak-load-none-regression
base: main
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.
+85
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| """Regression coverage for sloppak load failures in the highway websocket.""" | ||
|
|
||
| import asyncio | ||
| import importlib | ||
| import sys | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| class _CapturingWS: | ||
| def __init__(self): | ||
| self.messages = [] | ||
| self.accepted = False | ||
| self.closed = False | ||
| self.close_calls = 0 | ||
|
|
||
| async def accept(self): | ||
| self.accepted = True | ||
|
|
||
| async def send_json(self, data): | ||
| self.messages.append(data) | ||
|
|
||
| async def receive_text(self): | ||
| await asyncio.sleep(0) | ||
| return "" | ||
|
|
||
| async def close(self): | ||
| self.close_calls += 1 | ||
| self.closed = True | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
| @pytest.fixture() | ||
| def server(tmp_path, monkeypatch): | ||
| (tmp_path / "dlc").mkdir() | ||
| monkeypatch.setenv("CONFIG_DIR", str(tmp_path / "config")) | ||
| monkeypatch.setenv("DLC_DIR", str(tmp_path / "dlc")) | ||
| monkeypatch.setenv("FEEDBACK_SKIP_STARTUP_TASKS", "1") | ||
| sys.modules.pop("server", None) | ||
| mod = importlib.import_module("server") | ||
| yield mod, tmp_path / "dlc", tmp_path / "cache" | ||
| conn = getattr(getattr(mod, "meta_db", None), "conn", None) | ||
| if conn is not None: | ||
| getattr(mod, "_join_background_db_threads", lambda: None)() | ||
| conn.close() | ||
| sys.modules.pop("server", None) | ||
|
|
||
|
|
||
| def test_sloppak_loader_returning_none_sends_error_without_touching_stems( | ||
| server, monkeypatch | ||
| ): | ||
| _server, dlc, cache = server | ||
| (dlc / "broken.feedpak").mkdir() | ||
|
|
||
| import appstate | ||
| from routers import ws_highway | ||
|
|
||
| monkeypatch.setattr(appstate, "sloppak_cache_dir", cache) | ||
| monkeypatch.setattr(ws_highway.sloppak_mod, "load_song", lambda *a, **kw: None) | ||
|
|
||
| ws = _CapturingWS() | ||
| asyncio.run(ws_highway.highway_ws(ws, "broken.feedpak", arrangement=0)) | ||
|
|
||
| assert ws.accepted is True | ||
| assert ws.closed is True | ||
| assert ws.close_calls == 1 | ||
| assert ws.messages == [ | ||
| {"type": "loading", "stage": "Extracting..."}, | ||
| {"error": "Failed to load sloppak"}, | ||
| ] | ||
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.