-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPIK-360 Andrei/projects crud tests (#565)
* sanity fixes * projects crud automated tests * actions workflows * fixed typo * fixed sanity * removed on push activation --------- Co-authored-by: Andrei Căutișanu <[email protected]> Co-authored-by: Andrei Căutișanu <[email protected]>
- Loading branch information
1 parent
faed49e
commit 57e0056
Showing
15 changed files
with
410 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
import os | ||
from typing import Optional | ||
|
||
import opik | ||
from playwright.sync_api import Page | ||
from opik.rest_api.client import OpikApi | ||
|
||
from sdk_helpers import create_project_sdk, delete_project_by_name_sdk | ||
from page_objects.ProjectsPage import ProjectsPage | ||
|
||
|
||
@pytest.fixture(scope='function') | ||
def create_project_sdk_no_cleanup(): | ||
proj_name = 'projects_crud_tests_sdk' | ||
|
||
create_project_sdk(name=proj_name) | ||
yield proj_name | ||
|
||
|
||
@pytest.fixture(scope='function') | ||
def create_project_ui_no_cleanup(page: Page): | ||
proj_name = 'projects_crud_tests_ui' | ||
projects_page = ProjectsPage(page) | ||
projects_page.go_to_page() | ||
projects_page.create_new_project(project_name=proj_name) | ||
|
||
yield proj_name | ||
|
||
|
||
@pytest.fixture(scope='function') | ||
def create_delete_project_sdk(): | ||
proj_name = 'projects_crud_tests_sdk' | ||
|
||
create_project_sdk(name=proj_name) | ||
yield proj_name | ||
delete_project_by_name_sdk(name=proj_name) | ||
|
||
|
||
@pytest.fixture | ||
def create_delete_project_ui(page: Page): | ||
proj_name = 'projects_crud_tests_ui' | ||
projects_page = ProjectsPage(page) | ||
projects_page.go_to_page() | ||
projects_page.create_new_project(project_name=proj_name) | ||
|
||
yield proj_name | ||
delete_project_by_name_sdk(name=proj_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import pytest | ||
import os | ||
import time | ||
|
||
import opik | ||
from playwright.sync_api import Page | ||
from opik.rest_api.client import OpikApi | ||
|
||
|
||
def create_project_sdk(name: str): | ||
client = OpikApi() | ||
client.projects.create_project(name=name) | ||
|
||
|
||
def find_project_by_name_sdk(name: str): | ||
client = OpikApi() | ||
proj_page = client.projects.find_projects(name=name, page=1, size=1) | ||
return proj_page.dict()['content'] | ||
|
||
|
||
def delete_project_by_name_sdk(name: str): | ||
client = OpikApi() | ||
project = find_project_by_name_sdk(name=name) | ||
client.projects.delete_project_by_id(project[0]['id']) | ||
|
||
|
||
def wait_for_project_to_be_visible(project_name, timeout=10, initial_delay=1): | ||
start_time = time.time() | ||
delay = initial_delay | ||
|
||
while time.time() - start_time < timeout: | ||
if find_project_by_name_sdk(project_name): | ||
return True | ||
|
||
time.sleep(delay) | ||
delay = min(delay*2, timeout-(time.time() - start_time)) | ||
|
||
raise TimeoutError(f'could not get created project {project_name} via API within {timeout} seconds') | ||
|
||
|
||
def update_project_by_name_sdk(name: str, new_name: str): | ||
client = OpikApi() | ||
wait_for_project_to_be_visible(name, timeout=10) | ||
projects_match = find_project_by_name_sdk(name) | ||
project_id = projects_match[0]['id'] | ||
|
||
client.projects.update_project(id=project_id, name=new_name) | ||
|
||
return project_id |
Oops, something went wrong.