@@ -90,7 +90,7 @@ def test_CURDL_datagroup(request, mgmt_root):
9090 # Create
9191 ntf = NamedTemporaryFile (delete = False )
9292 ntf_basename = os .path .basename (ntf .name )
93- ntf .write ('"name1" := "value1",' )
93+ ntf .write (b '"name1" := "value1",' )
9494 ntf .seek (0 )
9595 # Upload the file
9696 mgmt_root .shared .file_transfer .uploads .upload_file (ntf .name )
@@ -103,7 +103,7 @@ def test_CURDL_datagroup(request, mgmt_root):
103103 assert dg1 .name == dg2 .name
104104
105105 # Rewrite the contents and update the object
106- ntf .write ('"name2" := "value2",' )
106+ ntf .write (b '"name2" := "value2",' )
107107 ntf .seek (0 )
108108 mgmt_root .shared .file_transfer .uploads .upload_file (ntf .name )
109109
@@ -120,6 +120,55 @@ def test_CURDL_datagroup(request, mgmt_root):
120120 assert dg1 .revision != dg4 .revision
121121
122122
123+ def setup_externalmonitor_test (request , mgmt_root , name , sourcepath , ** kwargs ):
124+ em1 = mgmt_root .tm .sys .file .external_monitors .external_monitor .create (name = name ,
125+ sourcePath = sourcepath ,
126+ ** kwargs )
127+
128+ def teardown ():
129+ # Remove the ifile.
130+ try :
131+ em1 .delete ()
132+ except HTTPError as err :
133+ if err .response .status_code != 404 :
134+ raise
135+
136+ request .addfinalizer (teardown )
137+
138+ return em1
139+
140+
141+ def test_CURDL_externalmonitor (request , mgmt_root ):
142+ # Create
143+ ntf = NamedTemporaryFile (delete = False )
144+ ntf_basename = os .path .basename (ntf .name )
145+ ntf .write (b'this is a test file' )
146+ ntf .seek (0 )
147+ # Upload the file
148+ mgmt_root .shared .file_transfer .uploads .upload_file (ntf .name )
149+
150+ tpath_name = 'file:/var/config/rest/downloads/{0}' .format (ntf_basename )
151+ em1 = setup_externalmonitor_test (request , mgmt_root , ntf_basename , tpath_name )
152+ assert em1 .name == ntf_basename
153+
154+ # Load Object
155+ em2 = mgmt_root .tm .sys .file .external_monitors .external_monitor .load (name = ntf_basename )
156+ assert em1 .name == em2 .name
157+
158+ # Rewrite file contents and Update Object
159+ ntf .write (b'this is still a test file' )
160+ ntf .seek (0 )
161+ mgmt_root .shared .file_transfer .uploads .upload_file (ntf .name )
162+
163+ em3 = mgmt_root .tm .sys .file .external_monitors .external_monitor .load (name = ntf_basename )
164+ em3 .update (sourcePath = tpath_name )
165+ assert em1 .revision != em3 .revision
166+
167+ # Refresh em2 and make sure revision matches em3
168+ em2 .refresh ()
169+ assert em2 .revision == em3 .revision
170+
171+
123172def setup_ifile_test (request , mgmt_root , name , sourcepath , ** kwargs ):
124173 if1 = mgmt_root .tm .sys .file .ifiles .ifile .create (name = name ,
125174 sourcePath = sourcepath ,
@@ -141,22 +190,21 @@ def test_CURDL_ifile(request, mgmt_root):
141190 # Create
142191 ntf = NamedTemporaryFile (delete = False )
143192 ntf_basename = os .path .basename (ntf .name )
144- ntf .write ('this is a test file' )
193+ ntf .write (b 'this is a test file' )
145194 ntf .seek (0 )
146195 # Upload the file
147196 mgmt_root .shared .file_transfer .uploads .upload_file (ntf .name )
148197
149198 tpath_name = 'file:/var/config/rest/downloads/{0}' .format (ntf_basename )
150- if1 = setup_ifile_test (request , mgmt_root , ntf_basename , tpath_name ,
151- )
199+ if1 = setup_ifile_test (request , mgmt_root , ntf_basename , tpath_name )
152200 assert if1 .name == ntf_basename
153201
154202 # Load Object
155203 if2 = mgmt_root .tm .sys .file .ifiles .ifile .load (name = ntf_basename )
156204 assert if1 .name == if2 .name
157205
158206 # Rewrite file contents and Update Object
159- ntf .write ('this is still a test file' )
207+ ntf .write (b 'this is still a test file' )
160208 ntf .seek (0 )
161209 mgmt_root .shared .file_transfer .uploads .upload_file (ntf .name )
162210
0 commit comments