1010import tempfile
1111from pathlib import Path
1212from typing import Tuple , Optional
13+ import pytest
1314import pycyphal
1415from pycyphal .transport .udp import UDPTransport
1516from tests .subprocess import Subprocess
1617
1718
1819async def _unittest_file_server_pnp () -> None :
1920 from pycyphal .application import make_node , NodeInfo , make_registry
20- from pycyphal .application .file import FileClient
21+ from pycyphal .application .file import FileClient2
2122 from pycyphal .application .plug_and_play import Allocatee
2223
2324 asyncio .get_running_loop ().slow_callback_duration = 10.0
@@ -28,24 +29,15 @@ async def _unittest_file_server_pnp() -> None:
2829 "file-server" ,
2930 root ,
3031 f"--plug-and-play={ root } /allocation_table.db" ,
31- environment_variables = {
32- "UAVCAN__UDP__IFACE" : "127.0.0.1" ,
33- "UAVCAN__NODE__ID" : "42" ,
34- },
32+ environment_variables = {"UAVCAN__UDP__IFACE" : "127.0.0.1" , "UAVCAN__NODE__ID" : "42" },
3533 )
3634 cln_node = make_node (
3735 NodeInfo (name = "org.opencyphal.yakut.test.file.client" ),
38- make_registry (
39- None ,
40- {
41- "UAVCAN__UDP__IFACE" : "127.0.0.1" ,
42- "UAVCAN__NODE__ID" : "43" ,
43- },
44- ),
36+ make_registry (None , {"UAVCAN__UDP__IFACE" : "127.0.0.1" , "UAVCAN__NODE__ID" : "43" }),
4537 )
4638 try :
47- fc = FileClient (cln_node , 42 , response_timeout = 30.0 ) # Large timeout is needed for Windows CI.
48- await asyncio .sleep (3 .0 ) # Let the server initialize.
39+ fc = FileClient2 (cln_node , 42 , response_timeout = 30.0 )
40+ await asyncio .sleep (10 .0 ) # Let the server initialize.
4941 assert srv_proc .alive
5042
5143 async def ls (path : str ) -> typing .List [str ]:
@@ -56,12 +48,13 @@ async def ls(path: str) -> typing.List[str]:
5648
5749 # Check the file server.
5850 assert ["allocation_table.db" ] == await ls ("/" )
59- assert 0 == await fc .touch ("/foo" )
51+ await fc .touch ("/foo" )
6052 assert ["allocation_table.db" , "foo" ] == await ls ("/" )
61- assert 0 == await fc .write ("/foo" , b"Hello world!" )
53+ await fc .write ("/foo" , b"Hello world!" )
6254 assert b"Hello world!" == await fc .read ("/foo" )
63- assert 0 == await fc .remove ("/foo" )
64- assert 0 != await fc .remove ("/foo" )
55+ await fc .remove ("/foo" )
56+ with pytest .raises (pycyphal .application .file .RemoteFileError ):
57+ await fc .remove ("/foo" )
6558 assert ["allocation_table.db" ] == await ls ("/" )
6659
6760 # Check the allocator.
0 commit comments