File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,9 @@ def get_remote_path(self):
131
131
str: path to the file on the remote host
132
132
"""
133
133
if isinstance (self .resource , NetworkResource ):
134
+ if self .rpath is None :
135
+ raise ManagedFileError ("sync_to_resource() needs to be called before the remote-path can be retrieved" )
136
+
134
137
return f"{ self .rpath } { os .path .basename (self .local_path )} "
135
138
136
139
return self .local_path
Original file line number Diff line number Diff line change 1
1
import os .path
2
+ import re
2
3
import subprocess
3
4
import socket
4
5
import atexit
14
15
from labgrid .util .helper import get_free_port
15
16
from labgrid .util .ssh import ForwardError , SSHConnection , sshmanager
16
17
from labgrid .util .proxy import proxymanager
17
- from labgrid .util .managedfile import ManagedFile
18
+ from labgrid .util .managedfile import ManagedFile , ManagedFileError
18
19
from labgrid .driver .exception import ExecutionError
19
20
from labgrid .resource .serialport import NetworkSerialPort
20
21
from labgrid .resource .common import Resource , NetworkResource
@@ -352,6 +353,22 @@ def test_local_managedfile(target, tmpdir):
352
353
assert hash == mf .get_hash ()
353
354
assert str (t ) == mf .get_remote_path ()
354
355
356
+ def test_network_managedfile_no_sync (target , tmpdir ):
357
+ import hashlib
358
+
359
+ res = NetworkResource (target , "localhost" , "test" )
360
+ t = tmpdir .join ("test" )
361
+ t .write (
362
+ """
363
+ Test
364
+ """
365
+ )
366
+ mf = ManagedFile (t , res , detect_nfs = False )
367
+
368
+ expected = re .escape ("sync_to_resource() needs to be called before the remote-path can be retrieved" )
369
+ with pytest .raises (ManagedFileError , match = expected ) as e :
370
+ mf .get_remote_path ()
371
+
355
372
356
373
def test_find_dict ():
357
374
dict_a = {"a" : {"a.a" : {"a.a.a" : "a.a.a_val" }}, "b" : "b_val" }
You can’t perform that action at this time.
0 commit comments