diff --git a/tests_end_to_end/tests/Datasets/test_datasets_crud_operations.py b/tests_end_to_end/tests/Datasets/test_datasets_crud_operations.py index 40d45d5eb0..6fe1b8af27 100644 --- a/tests_end_to_end/tests/Datasets/test_datasets_crud_operations.py +++ b/tests_end_to_end/tests/Datasets/test_datasets_crud_operations.py @@ -11,6 +11,12 @@ class TestDatasetsCrud: def test_create_dataset_ui_datasets_page(self, page: Page): + """ + Basic test to check dataset creation via UI. Uses the UI after creation to check the dataset exists + 1. Create dataset via UI from the datasets page + 2. Check the dataset exists in the dataset table + 3. If no errors raised, test passes + """ datasets_page = DatasetsPage(page) datasets_page.go_to_page() dataset_name = 'automated_tests_dataset' @@ -25,6 +31,13 @@ def test_create_dataset_ui_datasets_page(self, page: Page): def test_create_dataset_ui_add_traces_to_new_dataset(self, page: Page, create_delete_project_sdk, create_10_test_traces): + """ + Basic test to check dataset creation via "add to new dataset" functionality in the traces page. Uses the UI after creation to check the project exists + 1. Create a project with some traces + 2. Via the UI, select the traces and add them to a new dataset + 3. Switch to the datasets page, check the dataset exists in the dataset table + 4. If no errors raised and dataset exists, test passes + """ dataset_name = 'automated_tests_dataset' proj_name = create_delete_project_sdk projects_page = ProjectsPage(page) @@ -46,6 +59,12 @@ def test_create_dataset_ui_add_traces_to_new_dataset(self, page: Page, create_de def test_create_dataset_sdk_client(self, client: opik.Opik): + """ + Basic test to check dataset creation via SDK. Uses the SDK to fetch the created dataset to check it exists + 1. Create dataset via SDK Opik client + 2. Get the project via SDK OpikAPI client + 3. If dataset creation fails, client.get_dataset will throw an error and the test will fail. + """ dataset_name = 'automated_tests_dataset' try: client.create_dataset(name=dataset_name) @@ -60,6 +79,12 @@ def test_create_dataset_sdk_client(self, client: opik.Opik): @pytest.mark.parametrize('dataset_fixture', ['create_delete_dataset_ui', 'create_delete_dataset_sdk']) def test_dataset_visibility(self, request, page: Page, client: opik.Opik, dataset_fixture): + """ + Checks a created dataset is visible via both the UI and SDK. Test split in 2: checks on datasets created on both UI and SDK + 1. Create a dataset via the UI/the SDK (2 "instances" of the test created for each one) + 2. Fetch the dataset by name using the SDK Opik client and check the dataset exists in the datasets table in the UI + 3. Check that the correct dataset is returned in the SDK and that the name is correct in the UI + """ dataset_name = request.getfixturevalue(dataset_fixture) time.sleep(0.5) @@ -67,11 +92,19 @@ def test_dataset_visibility(self, request, page: Page, client: opik.Opik, datase datasets_page.go_to_page() datasets_page.check_dataset_exists_on_page_by_name(dataset_name) - assert client.get_dataset(dataset_name) is not None + dataset_sdk = client.get_dataset(dataset_name) + assert dataset_sdk.name == dataset_name @pytest.mark.parametrize('dataset_fixture', ['create_dataset_sdk_no_cleanup', 'create_dataset_ui_no_cleanup']) def test_dataset_name_update(self, request, page: Page, client: opik.Opik, dataset_fixture): + """ + Checks using the SDK update method on a dataset. Test split into 2: checks on dataset created on both UI and SDK + 1. Create a dataset via the UI/the SDK (2 "instances" of the test created for each one) + 2. Send a request via the SDK OpikApi client to update the dataset's name + 3. Check on both the SDK and the UI that the dataset has been renamed (on SDK: check dataset ID matches when sending a get by name reequest. on UI: check + dataset with new name appears and no dataset with old name appears) + """ dataset_name = request.getfixturevalue(dataset_fixture) time.sleep(0.5) new_name = 'updated_test_dataset_name' @@ -104,6 +137,12 @@ def test_dataset_name_update(self, request, page: Page, client: opik.Opik, datas @pytest.mark.parametrize('dataset_fixture', ['create_dataset_sdk_no_cleanup', 'create_dataset_ui_no_cleanup']) def test_dataset_deletion_in_sdk(self, request, page: Page, client: opik.Opik, dataset_fixture): + """ + Checks proper deletion of a dataset via the SDK. Test split into 2: checks on datasets created on both UI and SDK + 1. Create a dataset via the UI/the SDK (2 "instances" of the test created for each one) + 2. Send a request via the SDK to delete the dataset + 3. Check on both the SDK and the UI that the dataset no longer exists (client.get_dataset should throw a 404 error, dataset does not appear in datasets table in UI) + """ dataset_name = request.getfixturevalue(dataset_fixture) time.sleep(0.5) client.delete_dataset(name=dataset_name) @@ -122,6 +161,12 @@ def test_dataset_deletion_in_sdk(self, request, page: Page, client: opik.Opik, d @pytest.mark.parametrize('dataset_fixture', ['create_dataset_sdk_no_cleanup', 'create_dataset_ui_no_cleanup']) def test_dataset_deletion_in_ui(self, request, page: Page, client: opik.Opik, dataset_fixture): + """ + Checks proper deletion of a dataset via the SDK. Test split into 2: checks on datasets created on both UI and SDK + 1. Create a dataset via the UI/the SDK (2 "instances" of the test created for each one) + 2. Delete the dataset from the UI using the delete button in the datasets page + 3. Check on both the SDK and the UI that the dataset no longer exists (client.get_dataset should throw a 404 error, dataset does not appear in datasets table in UI) + """ dataset_name = request.getfixturevalue(dataset_fixture) time.sleep(0.5) datasets_page = DatasetsPage(page)