Skip to content

Commit d026241

Browse files
samyarpotlapallismlindauer
authored andcommitted
tests: adjustment to score_execution tests
1 parent cb775bf commit d026241

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/sasctl/_services/score_execution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def create_score_execution(
8989
if deleted_execution.status_code >= 400:
9090
raise HTTPError(
9191
{
92-
f"Something went wrong in the DELETE statement. See error: {score_execution.json()}"
92+
f"Something went wrong in the DELETE statement. See error: {deleted_execution.json()}"
9393
}
9494
)
9595

tests/unit/test_score_execution.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import unittest
1313
from pathlib import Path
1414
from unittest import mock
15+
from unittest.mock import MagicMock
1516

1617
import numpy as np
1718
import pandas as pd
@@ -55,15 +56,15 @@ def test_create_score_execution():
5556
get_definition.return_value.status_code = 404
5657
with pytest.raises(HTTPError):
5758
se.create_score_execution(
58-
score_definition_id="12345",
59+
score_definition_id="12345"
5960
)
6061
get_definition.return_value.status_code = 200
6162
get_definition.return_value.json.return_value = {
6263
"inputData": {
6364
"libraryName": "cas-shared-default",
6465
"tableName": ""
6566
},
66-
"name": "publish_automated_1720400011_2024-07-08T00:54:41.859Z",
67+
"name": "score_def_name",
6768
"objectDescriptor": {
6869
"name": "test_model",
6970
"type": "sas.publish.example",
@@ -73,16 +74,27 @@ def test_create_score_execution():
7374
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
7475
with pytest.raises(HTTPError):
7576
se.create_score_execution(
76-
score_definition_id="12345",
77+
score_definition_id="12345"
7778
)
7879

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
8484

85+
delete_execution.return_value.status_code = 404
86+
with pytest.raises(HTTPError):
87+
se.create_score_execution(
88+
score_definition_id="12345"
89+
)
8590

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()
8698

8799
#pytest.skip()
88100
# raise HTTP error?

0 commit comments

Comments
 (0)