@@ -20,6 +20,13 @@ def execute_example(self, input, apply, load=lambda: None):
2020 algo .init (input , pprint = lambda x : output .append (x ))
2121 return output [0 ]
2222
23+ def execute_manifest_example (self , input , apply , load , manifest_path = "good_model_manifest.json.lock" ):
24+ client = Algorithmia .client ()
25+ algo = ADK (apply , load , manifest_path = manifest_path , client = client )
26+ output = []
27+ algo .init (input , pprint = lambda x : output .append (x ))
28+ return output [0 ]
29+
2330 def execute_without_load (self , input , apply ):
2431 algo = ADK (apply )
2532 output = []
@@ -110,6 +117,32 @@ def test_binary_data(self):
110117 actual_output = json .loads (self .execute_without_load (input , apply_binary ))
111118 self .assertEqual (expected_output , actual_output )
112119
120+ def test_manifest_file_success (self ):
121+ input = "Algorithmia"
122+ expected_output = {'metadata' :
123+ {
124+ 'content_type' : 'text'
125+ },
126+ 'result' : "all model files were successfully loaded"
127+ }
128+ actual_output = json .loads (self .execute_manifest_example (input , apply_successful_manifest_parsing ,
129+ loading_with_manifest ,
130+ manifest_path = "tests/good_model_manifest.json.lock" ))
131+ self .assertEqual (expected_output , actual_output )
132+
133+ def test_manifest_file_tampered (self ):
134+ input = "Algorithmia"
135+ expected_output = {"error" : {"error_type" : "LoadingError" ,
136+ "message" : "Model File Mismatch for squeezenet\n "
137+ "expected hash: f20b50b44fdef367a225d41f747a0963\n "
138+ "real hash: 46a44d32d2c5c07f7f66324bef4c7266" ,
139+ "stacktrace" : "NoneType: None\n " }}
140+
141+ actual_output = json .loads (self .execute_manifest_example (input , apply_successful_manifest_parsing ,
142+ loading_with_manifest ,
143+ manifest_path = "tests/bad_model_manifest.json.lock" ))
144+ self .assertEqual (expected_output , actual_output )
145+
113146
114147def run_test ():
115148 unittest .main ()
0 commit comments