-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_labs.py
More file actions
60 lines (52 loc) · 1.7 KB
/
test_labs.py
File metadata and controls
60 lines (52 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from appwrite_lab.models import Lab
from appwrite_lab.labs import Labs
from appwrite_lab.automations.models import Expiration
import pytest
import uuid
@pytest.mark.e2e
def test_labs_new(lab: Lab):
assert lab.name == "test-lab"
assert lab.version == "1.7.4"
assert lab.url.endswith("80")
assert lab.projects.get("default") is not None
@pytest.mark.e2e
def test_labs_create_api_key(lab: Lab, lab_svc: Labs):
default = lab.projects.get("default")
if default.api_key:
pytest.skip("API key already exists")
res = lab_svc.create_api_key(
project_name=default.project_name,
key_name="default-api-key",
expiration=Expiration.THIRTY_DAYS,
lab=lab,
)
assert not res.error
assert type(res.data) is str
assert res.data.startswith("standard_")
@pytest.mark.e2e
def test_labs_synced_project(lab: Lab, lab_svc: Labs):
synced_proj_name = "KubeProject"
synced_proj = lab.projects.get(synced_proj_name)
assert synced_proj is not None
assert synced_proj.api_key.startswith("standard_")
assert synced_proj.project_name == "KubeProject"
@pytest.mark.e2e
def test_labs_create_project(lab: Lab, lab_svc: Labs):
nonce = str(uuid.uuid4())[:8]
project_name = f"test-project-{nonce}"
project_id = f"test-project-id-{nonce}"
res = lab_svc.create_project(
project_name=project_name,
project_id=project_id,
lab=lab,
)
assert not res.error
res = lab_svc.create_api_key(
project_name=project_name,
key_name=project_name,
expiration=Expiration.THIRTY_DAYS,
lab=lab,
)
assert not res.error
assert type(res.data) is str
assert res.data.startswith("standard_")