@@ -28,6 +28,22 @@ def check_cache_file_path(p_file, p_cache):
2828 assert str (p_file .relative_to (p_cache )).count ("/" ) == 2
2929
3030
31+ def construct_from_board (board ):
32+ prot = board .fs .protocol
33+ fs_name = prot if isinstance (prot , str ) else prot [0 ]
34+
35+ if fs_name == "file" :
36+ board = c .board_folder (board .board )
37+ elif fs_name == "rsc" :
38+ board = c .board_rsconnect (
39+ server_url = board .fs .api .server_url , api_key = board .fs .api .api_key
40+ )
41+ else :
42+ board = getattr (c , f"board_{ fs_name } " )(board .board )
43+
44+ return board
45+
46+
3147# End-to-end constructor tests
3248
3349# there are two facets of boards: reading and writing.
@@ -120,7 +136,7 @@ def test_constructor_board_github(tmp_cache, http_example_board_path, df_csv):
120136 check_cache_file_path (res [0 ], cache_dir )
121137
122138
123- @pytest .fixture (scope = "session " )
139+ @pytest .fixture (scope = "function " )
124140def board (backend ):
125141 # TODO: copied from test_compat.py
126142
@@ -129,23 +145,12 @@ def board(backend):
129145 backend .teardown_board (board )
130146
131147
132- def test_constructor_board (board , df_csv , tmp_cache ):
148+ def test_constructor_boards (board , df_csv , tmp_cache ):
133149 # TODO: would be nice to have fixtures for each board constructor
134150 # doesn't need to copy over pins-compat content
135151
136152 # create board from constructor -------------------------------------------
137-
138- prot = board .fs .protocol
139- fs_name = prot if isinstance (prot , str ) else prot [0 ]
140-
141- if fs_name == "file" :
142- board = c .board_folder (board .board )
143- elif fs_name == "rsc" :
144- board = c .board_rsconnect (
145- server_url = board .fs .api .server_url , api_key = board .fs .api .api_key
146- )
147- else :
148- board = getattr (c , f"board_{ fs_name } " )(board .board )
153+ board = construct_from_board (board )
149154
150155 # read a pin and check its contents ---------------------------------------
151156
@@ -157,7 +162,7 @@ def test_constructor_board(board, df_csv, tmp_cache):
157162 # check the cache structure -----------------------------------------------
158163
159164 # check cache
160- if fs_name == "file" :
165+ if board . fs . protocol == "file" :
161166 # no caching for local file boards
162167 pass
163168 else :
@@ -187,6 +192,33 @@ def test_constructor_board(board, df_csv, tmp_cache):
187192 assert orig_access < new_access
188193
189194
195+ @pytest .fixture (scope = "function" )
196+ def board2 (backend ):
197+ board2 = backend .create_tmp_board ()
198+ yield board2
199+ backend .teardown_board (board2 )
200+
201+
202+ def test_constructor_boards_multi_user (board2 , df_csv , tmp_cache ):
203+ prot = board2 .fs .protocol
204+ fs_name = prot if isinstance (prot , str ) else prot [0 ]
205+
206+ if fs_name == "rsc" :
207+ # TODO: RSConnect writes pin names like <user>/<name>, so would need to
208+ # modify test
209+ pytest .skip ()
210+
211+ first = construct_from_board (board2 )
212+
213+ first .pin_write (df_csv , "df_csv" , type = "csv" )
214+ assert first .pin_list () == ["df_csv" ]
215+
216+ second = construct_from_board (board2 )
217+ second .pin_write (df_csv , "another_df_csv" , type = "csv" )
218+
219+ assert sorted (second .pin_list ()) == sorted (["df_csv" , "another_df_csv" ])
220+
221+
190222# Board particulars ===========================================================
191223
192224
0 commit comments