10000 test with quotes in module name · Sivateja0689/python-sasctl@65107c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 65107c2

Browse files
committed
test with quotes in module name
1 parent b51195f commit 65107c2

File tree

1 file changed

+195
-0
lines changed

1 file changed

+195
-0
lines changed

tests/unit/test_microanalytic_score.py

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,198 @@ def test_define_steps():
171171

172172
for step in get_step.side_effect:
173173
assert hasattr(result, step.id)
174+
175+
176+
def test_define_steps_invalid_name():
177+
"""Verify that invalid characters are stripped."""
178+
179+
# Mock module to be returned
180+
# From bug reported by Paata
181+
module = RestObj({'createdBy': 'paata',
182+
'creationTimeStamp': '2020-03-02T15:37:57.811Z',
183+
'id': 'petshop_model_xgb_new',
184+
'language': 'ds2',
185+
'links': [{'href': '/microanalyticScore/modules',
186+
'itemType': 'application/vnd.sas.microanalytic.module',
187+
'method': 'GET',
188+
'rel': 'up',
189+
'type': 'application/vnd.sas.collection',
190+
'uri': '/microanalyticScore/modules'},
191+
{
192+
'href':
193+
'/microanalyticScore/modules/petshop_model_xgb_new',
194+
'method': 'GET',
195+
'rel': 'self',
196+
'type': 'application/vnd.sas.microanalytic.module',
197+
'uri':
198+
'/microanalyticScore/modules/petshop_model_xgb_new'},
199+
{
200+
'href':
201+
'/microanalyticScore/modules/petshop_model_xgb_new/source',
202+
'method': 'GET',
203+
'rel': 'source',
204+
'type':
205+
'application/vnd.sas.microanalytic.module.source',
206+
'uri':
207+
'/microanalyticScore/modules/petshop_model_xgb_new/source'},
208+
{
209+
'href':
210+
'/microanalyticScore/modules/petshop_model_xgb_new/steps',
211+
'itemType':
212+
'application/vnd.sas.microanalytic.module.step',
213+
'method': 'GET',
214+
'rel': 'steps',
215+
'type': 'application/vnd.sas.collection',
216+
'uri':
217+
'/microanalyticScore/modules/petshop_model_xgb_new/steps'},
218+
{
219+
'href':
220+
'/microanalyticScore/modules/petshop_model_xgb_new/submodules',
221+
'itemType':
222+
'application/vnd.sas.microanalytic.submodule',
223+
'method': 'GET',
224+
'rel': 'submodules',
225+
'type': 'application/vnd.sas.collection',
226+
'uri':
227+
'/microanalyticScore/modules/petshop_model_xgb_new/submodules'},
228+
{
229+
'href':
230+
'/microanalyticScore/modules/petshop_model_xgb_new',
231+
'method': 'PUT',
232+
'rel': 'update',
233+
'responseType':
234+
'application/vnd.sas.microanalytic.module',
235+
'type': 'application/vnd.sas.microanalytic.module',
236+
'uri':
237+
'/microanalyticScore/modules/petshop_model_xgb_new'},
238+
{
239+
'href':
240+
'/microanalyticScore/modules/petshop_model_xgb_new',
241+
'method': 'DELETE',
242+
'rel': 'delete',
243+
'uri':
244+
'/microanalyticScore/modules/petshop_model_xgb_new'}],
245+
'modifiedBy': 'paata',
246+
'modifiedTimeStamp': '2020-03-02T15:57:10.008Z',
247+
'name': '"petshop_model_XGB_new"',
248+
'properties': [{'name': 'sourceURI',
249+
'value': 'http://modelmanager/modelRepository/models/72facedf-8e36-418e-8145-1398686b997a'}],
250+
'revision': 0,
251+
'scope': 'public',
252+
'stepIds': ['score'],
253+
'version': 2,
254+
'warnings': []})
255+
256+
# Mock module step with multiple inputs
257+
step2 = RestObj({
258+
"id": "score",
259+
"inputs": [
260+
{
261+
"name": "age",
262+
"type": "decimal",
263+
"dim": 0,
264+
"size": 0
265+
},
266+
{
267+
"name": "b",
268+
"type": "decimal",
269+
"dim": 0,
270+
"size": 0
271+
},
272+
{
273+
"name": "chas",
274+
"type": "decimal",
275+
"dim": 0,
276+
"size": 0
277+
},
278+
{
279+
"name": "crim",
280+
"type": "decimal",
281+
"dim": 0,
282+
"size": 0
283+
},
284+
{
285+
"name": "dis",
286+
"type": "decimal",
287+
"dim": 0,
288+
"size": 0
289+
},
290+
{
291+
"name": "indus",
292+
"type": "decimal",
293+
"dim": 0,
294+
"size": 0
295+
},
296+
{
297+
"name": "lstat",
298+
"type": "decimal",
299+
"dim": 0,
300+
"size": 0
301+
},
302+
{
303+
"name": "nox",
304+
"type": "decimal",
305+
"dim": 0,
306+
"size": 0
307+
},
308+
{
309+
"name": "ptratio",
310+
"type": "decimal",
311+
"dim": 0,
312+
"size": 0
313+
},
314+
{
315+
"name": "rad",
316+
"type": "decimal",
317+
"dim": 0,
318+
"size": 0
319+
},
320+
{
321+
"name": "rm",
322+
"type": "decimal",
323+
"dim": 0,
324+
"size": 0
325+
},
326+
{
327+
"name": "tax",
328+
"type": "decimal",
329+
"dim": 0,
330+
"size": 0
331+
},
332+
{
333+
"name": "zn",
334+
"type": "decimal",
335+
"dim": 0,
336+
"size": 0
337+
}
338+
],
< DD2C code>339+
"outputs": [
340+
{
341+
"name": "em_prediction",
342+
"type": "decimal",
343+
"dim": 0,
344+
"size": 0
345+
},
346+
{
347+
"name": "p_price",
348+
"type": "decimal",
349+
"dim": 0,
350+
"size": 0
351+
},
352+
{
353+
"name": "_warn_",
354+
"type": "string",
355+
"dim": 0,
356+
"size": 4
357+
}
358+
]
359+
})
360+
361+
with mock.patch('sasctl._services.microanalytic_score.MicroAnalyticScore.get_module') as get_module:
362+
with mock.patch('sasctl._services.microanalytic_score.MicroAnalyticScore''.get_module_step') as get_step:
363+
get_module.return_value = module
364+
get_step.side_effect = [step2]
365+
result = mas.define_steps(None)
366+
367+
for step in get_step.side_effect:
368+
assert hasattr(result, step.id)

0 commit comments

Comments
 (0)
0