-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8d5347
commit c79dc47
Showing
8 changed files
with
443 additions
and
246 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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,18 +1,43 @@ | ||
import contextlib | ||
|
||
import streamlit | ||
import streamlit_webrtc.component | ||
|
||
from pyrobbot.app import app | ||
|
||
|
||
def test_app(mocker, default_voice_chat_configs): | ||
class MockAttrDict(dict): | ||
class MockAttrDict(streamlit.runtime.state.session_state_proxy.SessionStateProxy): | ||
def __getattr__(self, attr): | ||
return self.get(attr, mocker.MagicMock()) | ||
|
||
def __setattr__(self, attr, value): | ||
self[attr] = value | ||
def __getitem__(self, key): | ||
with contextlib.suppress(KeyError): | ||
return super().__getitem__(key) | ||
return mocker.MagicMock() | ||
|
||
mocker.patch("streamlit.session_state", MockAttrDict()) | ||
mocker.patch.object(streamlit, "session_state", new=MockAttrDict()) | ||
mocker.patch.object( | ||
streamlit.runtime.state.session_state_proxy, | ||
"SessionStateProxy", | ||
new=MockAttrDict, | ||
) | ||
mocker.patch("streamlit.chat_input", return_value="foobar") | ||
mocker.patch( | ||
"pyrobbot.chat_configs.VoiceChatConfigs.from_file", | ||
return_value=default_voice_chat_configs, | ||
) | ||
mocker.patch.object( | ||
streamlit_webrtc.component, | ||
"webrtc_streamer", | ||
mocker.MagicMock(return_value=mocker.MagicMock()), | ||
) | ||
|
||
mocker.patch("streamlit.number_input", return_value=0) | ||
|
||
mocker.patch( | ||
"pyrobbot.chat_configs.VoiceChatConfigs.model_validate", | ||
return_value=default_voice_chat_configs, | ||
) | ||
|
||
app.run_app() |