Skip to content

Commit

Permalink
tests: moved e2e according to user type
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreLeveau committed Oct 5, 2023
1 parent ece2d63 commit 9392828
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 25 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ jobs:
shell: bash
run: echo "KILI_SDK_VERSION=$(python -c "from kili import __version__; print(__version__)")" >> $GITHUB_ENV

- name: E2E tests
- name: E2E tests (org admin)
id: e2e
if: github.event.inputs.runE2ETests != 'false'
timeout-minutes: 60
run: pytest --timeout=600 -ra -sv --color yes --code-highlight yes --durations=0 -vv --ignore tests/e2e/test_notebooks.py tests/e2e
run: pytest --timeout=600 -ra -sv --color yes --code-highlight yes --durations=0 -vv tests/e2e/org_admin
env:
KILI_API_CLOUD_VISION: ${{ secrets.KILI_API_CLOUD_VISION }}
KILI_API_ENDPOINT: ${{ env.KILI_API_ENDPOINT }}
Expand All @@ -264,6 +264,19 @@ jobs:
KILI_USER_ID: ${{ secrets[format('KILI_USER_ID_{0}', env.TEST_AGAINST)] }}
KILI_TEST_DATA_INTEGRATION_ID: ${{ secrets.KILI_TEST_DATA_INTEGRATION_ID }}

- name: E2E tests (org user)
id: e2e_user
if: github.event.inputs.runE2ETests != 'false'
timeout-minutes: 60
run: pytest --timeout=600 -ra -sv --color yes --code-highlight yes --durations=0 -vv tests/e2e/org_user
env:
KILI_API_CLOUD_VISION: ${{ secrets.KILI_API_CLOUD_VISION }}
KILI_API_ENDPOINT: ${{ env.KILI_API_ENDPOINT }}
KILI_API_KEY: ${{ secrets[format('KILI_USER_API_KEY_{0}_USER', env.TEST_AGAINST)] }}
KILI_USER_EMAIL: ${{ secrets[format('KILI_USER_EMAIL_{0}', env.TEST_AGAINST)] }}
KILI_USER_ID: ${{ secrets[format('KILI_USER_ID_{0}', env.TEST_AGAINST)] }}
KILI_TEST_DATA_INTEGRATION_ID: ${{ secrets.KILI_TEST_DATA_INTEGRATION_ID }}

- name: Notebook tests
# we don't run notebook tests on push to main
# we run regardless of the outcome of the e2e tests
Expand Down
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions tests/e2e/org_admin/test_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import uuid

import pytest

from kili.client import Kili


@pytest.fixture()
def project_id(kili: Kili):
project_id = kili.create_project(
input_type="TEXT", json_interface={"jobs": {}}, title="test_tags.py e2e admin SDK"
)["id"]

yield project_id

kili.delete_project(project_id)


def test_given_org_with_tags_when_i_update_tag_then_it_is_updated(kili: Kili):
# Given
org_tags = kili.tags(fields=("label",))
assert len(org_tags) > 0, "Organization has no tags"
tag_to_update = next(tag for tag in org_tags if tag["label"])
prev_tag_name = tag_to_update["label"]

# When
new_tag_name = str(uuid.uuid4())
kili.update_tag(tag_name=prev_tag_name, new_tag_name=new_tag_name)

# Then
org_tags = kili.tags(fields=("label",))
assert len(org_tags) > 0, "Organization has no tags"
assert new_tag_name in [tag["label"] for tag in org_tags]

# Cleanup
kili.update_tag(tag_name=new_tag_name, new_tag_name=prev_tag_name)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 1 addition & 23 deletions tests/e2e/test_tags.py → tests/e2e/org_user/test_tags.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import uuid

import pytest

from kili.client import Kili
Expand All @@ -8,7 +6,7 @@
@pytest.fixture()
def project_id(kili: Kili):
project_id = kili.create_project(
input_type="TEXT", json_interface={"jobs": {}}, title="test_tags.py e2e SDK"
input_type="TEXT", json_interface={"jobs": {}}, title="test_tags.py e2e user SDK"
)["id"]

yield project_id
Expand Down Expand Up @@ -60,23 +58,3 @@ def test_given_project_with_tags_when_i_call_untag_project_then_it_removes_one_t
nb_tags_in_project_after = len(project_tags)
assert nb_tags_in_project_after == nb_tags_in_project_before - 1
assert not any(tag["label"] == tag_to_delete for tag in project_tags)


def test_given_org_with_tags_when_i_update_tag_then_it_is_updated(kili: Kili):
# Given
org_tags = kili.tags(fields=("label",))
assert len(org_tags) > 0, "Organization has no tags"
tag_to_update = next(tag for tag in org_tags if tag["label"])
prev_tag_name = tag_to_update["label"]

# When
new_tag_name = str(uuid.uuid4())
kili.update_tag(tag_name=prev_tag_name, new_tag_name=new_tag_name)

# Then
org_tags = kili.tags(fields=("label",))
assert len(org_tags) > 0, "Organization has no tags"
assert new_tag_name in [tag["label"] for tag in org_tags]

# Cleanup
kili.update_tag(tag_name=new_tag_name, new_tag_name=prev_tag_name)
File renamed without changes.

0 comments on commit 9392828

Please sign in to comment.