Skip to content

Commit 3e8d1f0

Browse files
committed
update tests
1 parent acb173f commit 3e8d1f0

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

tests/test_api/test_http.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time
33
import xmltodict
44
import pytest
5-
from openml.testing import TestAPIBase
5+
from openml.testing import TestBase, TestAPIBase
66
import os
77
from pathlib import Path
88
from urllib.parse import urljoin
@@ -155,27 +155,22 @@ def test_post_and_delete(self):
155155
<oml:input name="estimation_procedure">17</oml:input>
156156
</oml:task_inputs>
157157
"""
158+
# post
159+
response = self.http_client.post(
160+
"task",
161+
files={"description": task_xml},
162+
)
163+
self.assertEqual(response.status_code, 200)
164+
xml_resp = xmltodict.parse(response.content)
165+
task_id = int(xml_resp["oml:upload_task"]["oml:id"])
158166

159-
task_id = None
160-
try:
161-
# POST the task
162-
post_response = self.http_client.post(
163-
"task",
164-
files={"description": task_xml},
165-
)
166-
self.assertEqual(post_response.status_code, 200)
167-
xml_resp = xmltodict.parse(post_response.content)
168-
task_id = int(xml_resp["oml:upload_task"]["oml:id"])
169-
170-
# GET the task to verify it exists
171-
get_response = self.http_client.get(f"task/{task_id}")
172-
self.assertEqual(get_response.status_code, 200)
173-
174-
finally:
175-
# DELETE the task if it was created
176-
if task_id is not None:
177-
del_response = self.http_client.delete(f"task/{task_id}")
178-
self.assertEqual(del_response.status_code, 200)
167+
# cleanup incase of failure
168+
TestBase._mark_entity_for_removal("task", task_id)
169+
TestBase.logger.info(f"collected from {__file__}: {task_id}")
170+
171+
# delete
172+
response = self.http_client.delete(f"task/{task_id}")
173+
self.assertEqual(response.status_code, 200)
179174

180175
def test_download_requires_cache(self):
181176
client = HTTPClient(

tests/test_api/test_versions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from time import time
22
import pytest
3-
from openml.testing import TestAPIBase
3+
from openml.testing import TestBase, TestAPIBase
44
from openml._api import ResourceV1API, ResourceV2API, FallbackProxy, ResourceAPI
55
from openml.enums import ResourceType, APIVersion
66
from openml.exceptions import OpenMLNotSupportedError
@@ -18,13 +18,18 @@ def _publish_and_delete(self):
1818
<oml:input name="estimation_procedure">17</oml:input>
1919
</oml:task_inputs>
2020
"""
21-
21+
# publish
2222
task_id = self.resource.publish(
2323
"task",
2424
files={"description": task_xml},
2525
)
2626
self.assertIsNotNone(task_id)
2727

28+
# cleanup incase of failure
29+
TestBase._mark_entity_for_removal("task", task_id)
30+
TestBase.logger.info(f"collected from {__file__}: {task_id}")
31+
32+
# delete
2833
success = self.resource.delete(task_id)
2934
self.assertTrue(success)
3035

0 commit comments

Comments
 (0)