12
12
import unittest
13
13
from pathlib import Path
14
14
from unittest import mock
15
+ from unittest .mock import MagicMock
15
16
16
17
import numpy as np
17
18
import pandas as pd
@@ -55,15 +56,15 @@ def test_create_score_execution():
55
56
get_definition .return_value .status_code = 404
56
57
with pytest .raises (HTTPError ):
57
58
se .create_score_execution (
58
- score_definition_id = "12345" ,
59
+ score_definition_id = "12345"
59
60
)
60
61
get_definition .return_value .status_code = 200
61
62
get_definition .return_value .json .return_value = {
62
63
"inputData" : {
63
64
"libraryName" : "cas-shared-default" ,
64
65
"tableName" : ""
65
66
},
66
- "name" : "publish_automated_1720400011_2024-07-08T00:54:41.859Z " ,
67
+ "name" : "score_def_name " ,
67
68
"objectDescriptor" : {
68
69
"name" : "test_model" ,
69
70
"type" : "sas.publish.example" ,
@@ -73,16 +74,27 @@ def test_create_score_execution():
73
74
list_executions .return_value .status_code = 400 #we might need a separate try except here to show that 404 statement is weird and should exit the program
74
75
with pytest .raises (HTTPError ):
75
76
se .create_score_execution (
76
- score_definition_id = "12345" ,
77
+ score_definition_id = "12345"
77
78
)
78
79
79
- list_executions .return_value .status_code = 200
80
- list_executions .return_value .json .return_value = {
81
- "count" : 1
82
- }
83
- delete_execution .return_value .status_code = 2
80
+ mock_response = MagicMock ()
81
+ mock_response .status_code = 200
82
+ mock_response .json .return_value = {"count" : 1 }
83
+ list_executions .return_value = mock_response
84
84
85
+ delete_execution .return_value .status_code = 404
86
+ with pytest .raises (HTTPError ):
87
+ se .create_score_execution (
88
+ score_definition_id = "12345"
89
+ )
85
90
91
+ # delete_execution.return_value.status_code = 200
92
+ # response = se.create_score_execution(
93
+ # score_definition_id="12345"
94
+ # )
95
+ # assert response
96
+
97
+ test_create_score_execution ()
86
98
87
99
#pytest.skip()
88
100
# raise HTTP error?
0 commit comments