1212
1313
1414class Connection :
15- def __init__ (self ):
16- self .api = SumoClient (env = "dev" )
15+ def __init__ (self , token ):
16+ self .api = SumoClient (env = "dev" , token = token )
1717
1818
1919def _upload_parent_object (C , json ):
@@ -25,7 +25,7 @@ def _upload_parent_object(C, json):
2525
2626
2727def _upload_blob (C , blob , url = None , object_id = None ):
28- response = C .api .put ( f"/objects(' { object_id } ')/ blob" , blob = blob )
28+ response = C .api .blob_client . upload_blob ( blob = blob , url = url )
2929
3030 print ("Blob save " + str (response .status_code ), flush = True )
3131 if not 200 <= response .status_code < 202 :
@@ -76,15 +76,15 @@ class ValueKeeper:
7676""" TESTS """
7777
7878
79- def test_upload_search_delete_ensemble_child ():
79+ def test_upload_search_delete_ensemble_child (token ):
8080 """
8181 Testing the wrapper functionalities.
8282
8383 We upload an ensemble object along with a child. After that, we search for
8484 those objects to make sure they are available to the user. We then delete
8585 them and repeat the search to check if they were properly removed from sumo.
8686 """
87- C = Connection ()
87+ C = Connection (token )
8888 B = b"123456789"
8989
9090 # Upload Ensemble
@@ -113,9 +113,10 @@ def test_upload_search_delete_ensemble_child():
113113 assert isinstance (response_surface .json (), dict )
114114
115115 surface_id = response_surface .json ().get ("objectid" )
116+ blob_url = response_surface .json ().get ("blob_url" )
116117
117118 # Upload BLOB
118- response_blob = _upload_blob (C = C , blob = B , object_id = surface_id )
119+ response_blob = _upload_blob (C = C , blob = B , url = blob_url , object_id = surface_id )
119120 assert 200 <= response_blob .status_code <= 202
120121
121122 sleep (4 )
@@ -161,20 +162,20 @@ def test_upload_search_delete_ensemble_child():
161162 assert total == 0
162163
163164
164- def test_fail_on_wrong_metadata ():
165+ def test_fail_on_wrong_metadata (token ):
165166 """
166167 Upload a parent object with erroneous metadata, confirm failure
167168 """
168- C = Connection ()
169+ C = Connection (token )
169170 with pytest .raises (Exception ):
170171 assert _upload_parent_object (C = C , json = {"some field" : "some value" })
171172
172173
173- def test_upload_duplicate_ensemble ():
174+ def test_upload_duplicate_ensemble (token ):
174175 """
175176 Adding a duplicate ensemble, both tries must return same id.
176177 """
177- C = Connection ()
178+ C = Connection (token )
178179
179180 with open ("tests/testdata/case.yml" , "r" ) as stream :
180181 fmu_metadata1 = yaml .safe_load (stream )
0 commit comments