Skip to content

test: create "add csv to dataset" e2e test #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,20 @@ def csv_data():
2024-09-05T18:08:00Z,28,42
2024-09-05T18:09:00Z,29,41
"""


@pytest.fixture(scope="session")
def csv_data2():
return b"""\
timestamp,temperature,humidity
2024-09-05T18:10:00Z,30,40
2024-09-05T18:11:00Z,31,39
2024-09-05T18:12:00Z,32,38
2024-09-05T18:13:00Z,33,37
2024-09-05T18:14:00Z,34,36
2024-09-05T18:15:00Z,35,35
2024-09-05T18:16:00Z,36,34
2024-09-05T18:17:00Z,37,33
2024-09-05T18:18:00Z,38,32
2024-09-05T18:19:00Z,39,31
"""
20 changes: 20 additions & 0 deletions tests/e2e/test_sdk.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import timedelta
from unittest import mock
from uuid import uuid4

Expand Down Expand Up @@ -63,6 +64,25 @@ def test_add_dataset_to_run_and_list_datasets(csv_data):
assert ds2.rid == ds.rid


def test_add_csv_to_dataset(csv_data, csv_data2):
name = f"dataset-{uuid4()}"
desc = f"TESTING sdk to add more data to a dataset {uuid4()}"

with mock.patch("builtins.open", mock.mock_open(read_data=csv_data)):
ds = nm.upload_csv("fake_path.csv", name, "timestamp", "iso_8601", desc)
ds.poll_until_ingestion_completed(interval=timedelta(seconds=0.1))

with mock.patch("builtins.open", mock.mock_open(read_data=csv_data2)):
ds.add_csv_to_dataset("fake_path.csv", "timestamp", "iso_8601")
ds.poll_until_ingestion_completed(interval=timedelta(seconds=0.1))

assert ds.rid != ""
assert ds.name == name
assert ds.description == desc
assert len(ds.properties) == 0
assert len(ds.labels) == 0


def test_update_attachment(csv_data):
at_name = f"attachment-{uuid4()}"
at_desc = f"sdk to add a attachment to a run {uuid4()}"
Expand Down
Loading