Skip to content

Commit ae41977

Browse files
samyarpotlapallismlindauer
authored andcommitted
Adding frameworks for the rest of score_execution unit tests
1 parent f0984c4 commit ae41977

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

src/sasctl/_services/score_execution.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,9 @@ def create_score_execution(
7474
# Getting all score executions that are using the inputted score_definition_id
7575

7676
score_execution = cls.list_executions(filter=f"eq(scoreDefinitionId, '{score_definition_id}')")
77-
7877
if score_execution.status_code >= 400:
7978
raise HTTPError(
80-
{
81-
f"Something went wrong in the LIST_EXECUTIONS statement. See error: {score_execution.json()}"
82-
}
79+
f"Something went wrong in the LIST_EXECUTIONS statement. See error: {score_execution.json()}"
8380
)
8481

8582
# Checking the count of the execution list to see if there are any score executions for this score_definition_id already running
@@ -89,9 +86,7 @@ def create_score_execution(
8986
deleted_execution = cls.delete_execution(execution_id)
9087
if deleted_execution.status_code >= 400:
9188
raise HTTPError(
92-
{
9389
f"Something went wrong in the DELETE statement. See error: {deleted_execution.json()}"
94-
}
9590
)
9691

9792
headers_score_exec = {"Content-Type": "application/json"}

tests/unit/test_score_execution.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,42 @@ def test_create_score_execution():
7171
"uri": "/modelPublish/models/example"
7272
}
7373
}
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+
list_executions.return_value.status_code = 400 #test case worked with .return_value.status_code but caused an HTTP error that said error with list_Executions
7575
with pytest.raises(HTTPError):
7676
se.create_score_execution(
7777
score_definition_id="12345"
7878
)
7979

80-
list_executions.status_code = 200
80+
list_executions.status_code = 200 #why does this not have a return value and how is this related to different score_Defintion instantiation in score_execution
8181
list_executions.return_value.json.return_value = {"count": 1}
82-
8382
delete_execution.return_value.status_code = 404
8483
with pytest.raises(HTTPError):
8584
se.create_score_execution(
8685
score_definition_id="12345"
8786
)
87+
#Test cases that don't work or I haven't tested
88+
delete_execution.return_value.status_code = 200
89+
response = se.create_score_execution(
90+
score_definition_id="3456"
91+
)
92+
assert response
93+
94+
list_executions.status_code = 200 #shouldn't this work with 200 response and not give me a type rror >= since it's not running 400 statement
95+
96+
list_executions.return_value.json.return_value = {"count": 0}
97+
response = se.create_score_execution(
98+
score_definition_id="12345"
99+
)
100+
assert response
101+
102+
list_executions.status_code = 200
103+
list_executions.return_value.json.return_value = {"count": 0}
104+
response = se.create_score_execution(
105+
score_definition_id="12345",
106+
output_table_name = "test_output_table"
107+
)
108+
assert response #target needed here to test with and without specified output_table_name
88109

89-
# delete_execution.return_value.status_code = 200
90-
# response = se.create_score_execution(
91-
# score_definition_id="12345"
92-
# )
93-
# assert response
94110

95111
#pytest.skip()
96112
# raise HTTP error?

0 commit comments

Comments
 (0)