Skip to content

Commit

Permalink
Merge branch 'develop' into docs/onboarding_improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon authored Jul 30, 2024
2 parents f5abbac + 407bd4a commit e18e54b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 43 deletions.
11 changes: 8 additions & 3 deletions argilla/tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@
@pytest.fixture(scope="session")
def client() -> rg.Argilla:
client = rg.Argilla()

if len(list(client.workspaces)) == 0:
client.workspaces.add(rg.Workspace(name=f"test_{uuid.uuid4()}"))

yield client

_cleanup(client)


@pytest.fixture(autouse=True)
def cleanup(client: rg.Argilla):
def _cleanup(client: rg.Argilla):
for workspace in client.workspaces:
if workspace.name.startswith("test_"):
for dataset in workspace.datasets:
Expand All @@ -46,7 +51,7 @@ def dataset_name() -> str:

@pytest.fixture
def workspace(client: Argilla) -> Workspace:
ws_name = "test-workspace"
ws_name = f"test-{uuid.uuid4()}"

workspace = client.workspaces(ws_name)
if workspace is None:
Expand Down
2 changes: 1 addition & 1 deletion argilla/tests/integration/test_add_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


def test_create_dataset(client):
workspace = client.workspaces[0]
workspace = client.workspaces.default
mock_dataset_name = f"test_create_dataset{datetime.now().strftime('%Y%m%d%H%M%S')}"
dataset = rg.Dataset(
name=mock_dataset_name,
Expand Down
11 changes: 0 additions & 11 deletions argilla/tests/integration/test_create_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pytest

from argilla import (
Argilla,
Dataset,
Expand All @@ -28,15 +26,6 @@
from argilla.settings._task_distribution import TaskDistribution


@pytest.fixture(scope="session", autouse=True)
def clean_datasets(client: Argilla):
datasets = client.datasets
for dataset in datasets:
if dataset.name.startswith("test_"):
dataset.delete()
yield


class TestCreateDatasets:
def test_create_dataset(self, client: Argilla, dataset_name: str):
dataset = Dataset(
Expand Down
11 changes: 0 additions & 11 deletions argilla/tests/integration/test_dataset_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
from argilla._exceptions import NotFoundError


@pytest.fixture(autouse=True, scope="session")
def clean_test_datasets(client: rg.Argilla):
for dataset in client.datasets:
if dataset.name.startswith("test_"):
dataset.delete()
yield
for dataset in client.datasets:
if dataset.name.startswith("test_"):
dataset.delete()


@pytest.fixture
def dataset(client: rg.Argilla):
ws = client.workspaces[0]
Expand Down
22 changes: 6 additions & 16 deletions argilla/tests/integration/test_manage_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,37 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid

import pytest

from argilla import User, Argilla, Workspace
from argilla._exceptions import UnprocessableEntityError


@pytest.fixture(scope="session", autouse=True)
def clean_environment(client: Argilla):
for user in client.users:
if user.username.startswith("test"):
user.delete()
yield
for user in client.users:
if user.username.startswith("test"):
user.delete()


class TestManageUsers:
def test_create_user(self, client: Argilla):
user = User(username="test_user", password="test_password")
user = User(username=f"test_user_{uuid.uuid4()}", password="test_password")
client.users.add(user)
assert user.id is not None
assert client.users(username=user.username).id == user.id

def test_create_user_without_password(self, client: Argilla):
user = User(username="test_user")
user = User(username=f"test_user_{uuid.uuid4()}")
with pytest.raises(expected_exception=UnprocessableEntityError):
client.users.add(user)

def test_delete_user(self, client: Argilla):
user = User(username="test_delete_user", password="test_password")
user = User(username=f"test_delete_user_{uuid.uuid4()}", password="test_password")
client.users.add(user)
user.delete()
assert not client.api.users.exist(user.id)

def test_add_user_to_workspace(self, client: Argilla, workspace: Workspace):
user = User(username="test_user", password="test_password")
user = User(username=f"test_user_{uuid.uuid4()}", password="test_password")
client.users.add(user)

user = client.users(username="test_user")
user = client.users(username=user.username)
assert user.password is None

user.add_to_workspace(workspace)
Expand Down
3 changes: 2 additions & 1 deletion argilla/tests/integration/test_manage_workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import uuid

from argilla import Argilla, Workspace, User


class TestWorkspacesManagement:
def test_create_workspace(self, client: Argilla):
workspace = Workspace(name="test_workspace")
workspace = Workspace(name=f"test_workspace{uuid.uuid4()}")
client.workspaces.add(workspace)

assert workspace in client.workspaces
Expand Down

0 comments on commit e18e54b

Please sign in to comment.