Skip to content

Commit e5a8294

Browse files
test: update the integration test file
1 parent cac3801 commit e5a8294

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

tests/integration/artifact/test_artifact.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import io
2-
import os
32
from typing import List
43

54
import pytest
65
from nisystemlink.clients.artifact import ArtifactClient
76
from nisystemlink.clients.artifact.models._upload_artifact_response import (
87
UploadArtifactResponse,
98
)
10-
from nisystemlink.clients.core._api_exception import ApiException
119
from nisystemlink.clients.core._http_configuration import HttpConfiguration
1210

1311

@@ -17,36 +15,25 @@ def client(enterprise_config: HttpConfiguration) -> ArtifactClient:
1715
return ArtifactClient(enterprise_config)
1816

1917

20-
def get_workspace() -> str:
21-
"""Get the workspace ID from environment variables or skip the test if not set."""
22-
workspace = os.getenv("SYSTEMLINK_WORKSPACE_ID")
23-
if workspace is None:
24-
pytest.skip("SYSTEMLINK_WORKSPACE_ID environment variable is not set.")
25-
26-
return workspace
27-
28-
2918
@pytest.fixture
3019
def create_artifact(client: ArtifactClient):
3120
"""Fixture to return a factory that creates artifact."""
3221
created_artifact_ids: List[str] = []
3322

34-
def _create_artifact(content: bytes = b"test content"):
35-
workspace = get_workspace()
23+
def _create_artifact(content: bytes = b"test content", cleanup: bool = True):
3624
artifact_stream = io.BytesIO(content)
37-
response = client.upload_artifact(workspace=workspace, artifact=artifact_stream)
38-
created_artifact_ids.append(response.id)
25+
response = client.upload_artifact(
26+
workspace="2300760d-38c4-48a1-9acb-800260812337", artifact=artifact_stream
27+
)
28+
if cleanup:
29+
created_artifact_ids.append(response.id)
3930

4031
return response
4132

4233
yield _create_artifact
4334

4435
for artifact_id in created_artifact_ids:
45-
try:
46-
client.delete_artifact(artifact_id)
47-
except ApiException as api_exception:
48-
if api_exception.http_status_code != 404:
49-
raise api_exception
36+
client.delete_artifact(artifact_id)
5037

5138

5239
@pytest.mark.integration
@@ -78,7 +65,7 @@ def test__download_artifact__artifact_downloaded(
7865
def test__delete_artifact__artifact_deleted(
7966
self, client: ArtifactClient, create_artifact
8067
):
81-
upload_response: UploadArtifactResponse = create_artifact()
68+
upload_response: UploadArtifactResponse = create_artifact(cleanup=False)
8269
artifact_id = upload_response.id
8370

8471
delete_response = client.delete_artifact(artifact_id)

0 commit comments

Comments
 (0)