1414def test_drivers_mock_storage_mux_fs (monkeypatch : pytest .MonkeyPatch ):
1515 with serve (MockStorageMux ()) as client :
1616 with TemporaryDirectory () as tempdir :
17+ # original file on the client to be pushed to the exporter
1718 original = Path (tempdir ) / "original"
19+ # new file read back from the exporter to the client
1820 readback = Path (tempdir ) / "readback"
1921
20- # absolute path
22+ # test accessing files with absolute path
23+
24+ # fill the original file with random bytes
2125 original .write_bytes (randbytes (1024 * 1024 * 10 ))
26+ # write the file to the storage on the exporter
2227 client .write_local_file (str (original ))
28+ # read the storage on the exporter to a local file
2329 client .read_local_file (str (readback ))
30+ # ensure the contents are equal
2431 assert original .read_bytes () == readback .read_bytes ()
2532
26- # relative path
33+ # test accessing files with relative path
2734 with monkeypatch .context () as m :
2835 m .chdir (tempdir )
2936
@@ -39,6 +46,7 @@ def test_drivers_mock_storage_mux_fs(monkeypatch: pytest.MonkeyPatch):
3946
4047
4148def test_drivers_mock_storage_mux_http ():
49+ # dummy HTTP server returning static test content
4250 class StaticHandler (BaseHTTPRequestHandler ):
4351 def do_HEAD (self ):
4452 self .send_response (200 )
@@ -52,11 +60,13 @@ def do_GET(self):
5260 self .wfile .write (b"testcontent" * 1000 )
5361
5462 with serve (MockStorageMux ()) as client :
63+ # start the HTTP server
5564 server = HTTPServer (("127.0.0.1" , 8080 ), StaticHandler )
5665 server_thread = Thread (target = server .serve_forever )
5766 server_thread .daemon = True
5867 server_thread .start ()
5968
69+ # write a remote file from the http server to the exporter
6070 fs = Operator ("http" , endpoint = "http://127.0.0.1:8080" )
6171 client .write_file (fs , "test" )
6272
0 commit comments