22import pytest
33
44import tests .types as test_types
5- from nipanel . _streamlit_panel import StreamlitPanel
5+ from nipanel import StreamlitPanel , StreamlitPanelValueAccessor
66from tests .utils ._fake_python_panel_service import FakePythonPanelService
77
88
@@ -12,6 +12,17 @@ def test___panel___has_panel_id_and_panel_uri() -> None:
1212 assert panel .panel_uri == "path/to/script"
1313
1414
15+ def test___different_panels___have_different_panel_ids_and_uris () -> None :
16+ panel1 = StreamlitPanel ("panel1" , "path/to/script1" )
17+ panel2 = StreamlitPanel ("panel2" , "path/to/script2" )
18+
19+ assert panel1 .panel_id == "panel1"
20+ assert panel2 .panel_id == "panel2"
21+ assert panel1 ._panel_uri == "path/to/script1"
22+ assert panel2 ._panel_uri == "path/to/script2"
23+ assert panel1 ._panel_client != panel2 ._panel_client
24+
25+
1526def test___opened_panel___set_value___gets_same_value (
1627 fake_panel_channel : grpc .Channel ,
1728) -> None :
@@ -25,6 +36,34 @@ def test___opened_panel___set_value___gets_same_value(
2536 assert panel .get_value (value_id ) == string_value
2637
2738
39+ def test___opened_panel___panel_set_value___accessor_gets_same_value (
40+ fake_panel_channel : grpc .Channel ,
41+ ) -> None :
42+ panel = StreamlitPanel ("my_panel" , "path/to/script" , grpc_channel = fake_panel_channel )
43+ panel .open_panel ()
44+ accessor = StreamlitPanelValueAccessor ("my_panel" , grpc_channel = fake_panel_channel )
45+
46+ value_id = "test_id"
47+ string_value = "test_value"
48+ panel .set_value (value_id , string_value )
49+
50+ assert accessor .get_value (value_id ) == string_value
51+
52+
53+ def test___opened_panel___accessor_set_value___panel_gets_same_value (
54+ fake_panel_channel : grpc .Channel ,
55+ ) -> None :
56+ panel = StreamlitPanel ("my_panel" , "path/to/script" , grpc_channel = fake_panel_channel )
57+ panel .open_panel ()
58+ accessor = StreamlitPanelValueAccessor ("my_panel" , grpc_channel = fake_panel_channel )
59+
60+ value_id = "test_id"
61+ string_value = "test_value"
62+ accessor .set_value (value_id , string_value )
63+
64+ assert panel .get_value (value_id ) == string_value
65+
66+
2867def test___first_open_panel_fails___open_panel___gets_value (
2968 fake_python_panel_service : FakePythonPanelService ,
3069 fake_panel_channel : grpc .Channel ,
0 commit comments