proximl 0.5.8__py3-none-any.whl → 0.5.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- proximl/cli/project/__init__.py +153 -0
- proximl/cli/project/key.py +124 -0
- proximl/cli/project/secret.py +71 -0
- proximl/projects/__init__.py +3 -0
- proximl/projects/data_connectors.py +63 -0
- proximl/projects/datastores.py +58 -0
- proximl/projects/keys.py +71 -0
- proximl/projects/projects.py +83 -0
- proximl/projects/secrets.py +70 -0
- proximl/projects/services.py +63 -0
- {proximl-0.5.8.dist-info → proximl-0.5.9.dist-info}/METADATA +1 -1
- {proximl-0.5.8.dist-info → proximl-0.5.9.dist-info}/RECORD +30 -6
- tests/integration/projects/__init__.py +0 -0
- tests/integration/projects/conftest.py +8 -0
- tests/integration/projects/test_projects_integration.py +38 -0
- tests/integration/projects/test_projects_keys_integration.py +43 -0
- tests/integration/projects/test_projects_secrets_integration.py +44 -0
- tests/unit/projects/__init__.py +0 -0
- tests/unit/projects/test_project_data_connectors_unit.py +102 -0
- tests/unit/projects/test_project_datastores_unit.py +96 -0
- tests/unit/projects/test_project_keys_unit.py +96 -0
- tests/unit/projects/test_project_secrets_unit.py +101 -0
- tests/unit/projects/test_project_services_unit.py +102 -0
- tests/unit/projects/test_projects_unit.py +128 -0
- tests/unit/test_auth_unit.py +30 -0
- tests/unit/test_proximl_unit.py +54 -0
- {proximl-0.5.8.dist-info → proximl-0.5.9.dist-info}/LICENSE +0 -0
- {proximl-0.5.8.dist-info → proximl-0.5.9.dist-info}/WHEEL +0 -0
- {proximl-0.5.8.dist-info → proximl-0.5.9.dist-info}/entry_points.txt +0 -0
- {proximl-0.5.8.dist-info → proximl-0.5.9.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ProjectServices(object):
|
|
6
|
+
def __init__(self, proximl, project_id):
|
|
7
|
+
self.proximl = proximl
|
|
8
|
+
self.project_id = project_id
|
|
9
|
+
|
|
10
|
+
async def list(self, **kwargs):
|
|
11
|
+
resp = await self.proximl._query(
|
|
12
|
+
f"/project/{self.project_id}/services", "GET", kwargs
|
|
13
|
+
)
|
|
14
|
+
services = [ProjectService(self.proximl, **service) for service in resp]
|
|
15
|
+
return services
|
|
16
|
+
|
|
17
|
+
async def refresh(self):
|
|
18
|
+
await self.proximl._query(f"/project/{self.project_id}/services", "PATCH")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ProjectService:
|
|
22
|
+
def __init__(self, proximl, **kwargs):
|
|
23
|
+
self.proximl = proximl
|
|
24
|
+
self._entity = kwargs
|
|
25
|
+
self._id = self._entity.get("id")
|
|
26
|
+
self._project_uuid = self._entity.get("project_uuid")
|
|
27
|
+
self._name = self._entity.get("name")
|
|
28
|
+
self._hostname = self._entity.get("hostname")
|
|
29
|
+
self._public = self._entity.get("public")
|
|
30
|
+
self._region_uuid = self._entity.get("region_uuid")
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def id(self) -> str:
|
|
34
|
+
return self._id
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def project_uuid(self) -> str:
|
|
38
|
+
return self._project_uuid
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def name(self) -> str:
|
|
42
|
+
return self._name
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def hostname(self) -> str:
|
|
46
|
+
return self._hostname
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def public(self) -> bool:
|
|
50
|
+
return self._public
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def region_uuid(self) -> str:
|
|
54
|
+
return self._region_uuid
|
|
55
|
+
|
|
56
|
+
def __str__(self):
|
|
57
|
+
return json.dumps({k: v for k, v in self._entity.items()})
|
|
58
|
+
|
|
59
|
+
def __repr__(self):
|
|
60
|
+
return f"ProjectService( proximl , **{self._entity.__repr__()})"
|
|
61
|
+
|
|
62
|
+
def __bool__(self):
|
|
63
|
+
return bool(self._id)
|
|
@@ -36,6 +36,9 @@ proximl/cli/cloudbender/reservation.py,sha256=xzHs5l8BbmYgKUq6kfFU-jEtRQY0j_vYnm
|
|
|
36
36
|
proximl/cli/cloudbender/service.py,sha256=YimwXQml82-PKKQIqu9Cvggo9wOKLVTJPxMvDf4pgn8,2869
|
|
37
37
|
proximl/cli/job/__init__.py,sha256=s8mU2PvCWDcv4gGT3EmjHn8MIZlXBAoayoZKmnKpXnY,6545
|
|
38
38
|
proximl/cli/job/create.py,sha256=sGvbenY0yxvxHo-FZVbdw8FaZx5D4ekTCjD7P4YHG4g,34288
|
|
39
|
+
proximl/cli/project/__init__.py,sha256=VhBZb1WAbe9NCTrYRl4aRNppFn1loDDMQ-cTqBCeV7A,3402
|
|
40
|
+
proximl/cli/project/key.py,sha256=23ugcWOAxNJvC8VzG3FsEUWJ1_FZANnhq66cO04ZEVY,3203
|
|
41
|
+
proximl/cli/project/secret.py,sha256=uys2FsXuO_8_EoolQNuOZ9btX4I0LXBeKG8dGx6StMM,1621
|
|
39
42
|
proximl/cloudbender/__init__.py,sha256=iE29obtC0_9f0IhRvHQcG5aY58fVhVYipTakpjAhdss,64
|
|
40
43
|
proximl/cloudbender/cloudbender.py,sha256=E1_MyOhl-Fq5gr6vitCdI34_f24Pa5cg9YrFXIXPwg8,634
|
|
41
44
|
proximl/cloudbender/data_connectors.py,sha256=urhmaAi4TBR-6L1CD2qS7SG3Dcwo9hOi8Gx613MzKVU,3297
|
|
@@ -47,6 +50,13 @@ proximl/cloudbender/providers.py,sha256=cH5lCew5WCFpXYS93vuoGNWkZyx7T_mdMH6YNWp2
|
|
|
47
50
|
proximl/cloudbender/regions.py,sha256=Nu1LT6nuLD8Nt-5-7_FLlxDNZoDDAY6QduTdEBqfxJA,3570
|
|
48
51
|
proximl/cloudbender/reservations.py,sha256=14ImJRLWQGG7CXDYhDnOI2W8pnP6CVVG2aVpysQVN0E,3586
|
|
49
52
|
proximl/cloudbender/services.py,sha256=KR0EQ-BUVk1ov9Q195NsnfiSiMb9vOYD8XyxD87RRvw,3222
|
|
53
|
+
proximl/projects/__init__.py,sha256=6NKCcHtQMeGB1IyU-djANphfnDX6MEkrXUM5Fyq9fWg,75
|
|
54
|
+
proximl/projects/data_connectors.py,sha256=559yJ-9qmva2JcNReuCyUQxdrSRIEROcGX5BDVr8ySs,1662
|
|
55
|
+
proximl/projects/datastores.py,sha256=zAmKX9CibeS7PSXVvExk0SVrEo9Zq83kz6CQw0GoHck,1560
|
|
56
|
+
proximl/projects/keys.py,sha256=yT5pgv1mGm50CaORf-HnsbDULad69G9I_QpVMN0zcuE,2157
|
|
57
|
+
proximl/projects/projects.py,sha256=3aEGHxOMYbO9FaLSzSAA94A5ZGzljq-fBJk1QcSidCE,2755
|
|
58
|
+
proximl/projects/secrets.py,sha256=NxjP1_CR9UQUMazeS-esin3zH54xZ4b4R11YNSU4hsI,2157
|
|
59
|
+
proximl/projects/services.py,sha256=Jian2RHV9u3pHQKa7AsHKj25DrR4DstB-JaIDhSu7Tw,1679
|
|
50
60
|
tests/integration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
51
61
|
tests/integration/conftest.py,sha256=zRWpherX-yfbpk7xqZk9bIZCyJ-dwVeszY_7kekn2M4,1134
|
|
52
62
|
tests/integration/test_checkpoints_integration.py,sha256=DUA6ZlX0gsnKCEvFmWCKbKkfJG3dQG6uD8T3fgo7y0M,3230
|
|
@@ -59,9 +69,15 @@ tests/integration/test_projects_integration.py,sha256=XdGGqvOQby77kMfoD_zAukKvN6
|
|
|
59
69
|
tests/integration/test_volumes_integration.py,sha256=Xo2Whw2U-7jyvESIkyex3f0SMXKlExe3kLmsbpXTHhQ,3270
|
|
60
70
|
tests/integration/cloudbender/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
61
71
|
tests/integration/cloudbender/test_providers_integration.py,sha256=gFqPQom-Cn1iZC50_ChQ2us2_f4tIPATQSAUcWdf7ss,1473
|
|
72
|
+
tests/integration/projects/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
|
+
tests/integration/projects/conftest.py,sha256=UW9t62xiBRfU3anBRB-sdURD2eqo7xVAUsfTGsgWpcQ,208
|
|
74
|
+
tests/integration/projects/test_projects_integration.py,sha256=wlRLxZkMnJZHlNPaeRFjAeyUlMfbgdrrFEI2eMBcoUI,1241
|
|
75
|
+
tests/integration/projects/test_projects_keys_integration.py,sha256=cLvka_XlQHCYAFX4-gsH57KzhnpQZOGRvk9Q-HZEYbI,1423
|
|
76
|
+
tests/integration/projects/test_projects_secrets_integration.py,sha256=Q8GEJkBE4X38F36sJza3VRo1pWdF9qEEr2kuADqgBB8,1478
|
|
62
77
|
tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
63
78
|
tests/unit/conftest.py,sha256=dilDp7ZSmyg9tJbkJoGcqUF07JBTdkNoULOR6qK7NsU,31197
|
|
64
79
|
tests/unit/test_auth.py,sha256=IJZHT5CZLNfu3MybTdEWIsKlvxNfFYpZ6oWYzbS856g,858
|
|
80
|
+
tests/unit/test_auth_unit.py,sha256=IJZHT5CZLNfu3MybTdEWIsKlvxNfFYpZ6oWYzbS856g,858
|
|
65
81
|
tests/unit/test_checkpoints_unit.py,sha256=WfFE6HvQHglBKfcJ3B0IYXdXpaNmcL2BDurRQmIbFAU,16008
|
|
66
82
|
tests/unit/test_connections_unit.py,sha256=LFAZzlrvL9oM8rZJTiC1oA9quw1KA2vMUCc3LV6SjXs,5507
|
|
67
83
|
tests/unit/test_datasets_unit.py,sha256=Bw6bw2Dhe3BPi2KAM-2S3PKBJO9hMRdTWMECA2lfhJU,15879
|
|
@@ -72,6 +88,7 @@ tests/unit/test_jobs_unit.py,sha256=kCrm2FdogqYgji0Coe9KGaODYEsXmvuV46FN2mUE1Ts,
|
|
|
72
88
|
tests/unit/test_models_unit.py,sha256=wgwdvJLt6QZ_IKCvp6Kmt2Z4b_CvIN8KCuFqlBaxDe8,15064
|
|
73
89
|
tests/unit/test_projects_unit.py,sha256=_SwPFhy2Xl6HRt6w5_HYrqtZJHAzFzoCZ3kqAS1Zn3c,9530
|
|
74
90
|
tests/unit/test_proximl.py,sha256=E-er5V1O-4ZVfTO2R-2wGsKN80q0_BVG5ho9Ab9lnE4,1701
|
|
91
|
+
tests/unit/test_proximl_unit.py,sha256=E-er5V1O-4ZVfTO2R-2wGsKN80q0_BVG5ho9Ab9lnE4,1701
|
|
75
92
|
tests/unit/test_volumes_unit.py,sha256=YcyrGPCq7XfAtCdKdp44723o7mLGIu5_hKOdhAFVYV4,15305
|
|
76
93
|
tests/unit/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
77
94
|
tests/unit/cli/conftest.py,sha256=w6p_2URicywJKUCtY79tSD_mx8cwJtxHbK_Lu3grOYs,236
|
|
@@ -101,9 +118,16 @@ tests/unit/cloudbender/test_providers_unit.py,sha256=y63VCqHXb4Yu8sh0kW30-ojRvv9
|
|
|
101
118
|
tests/unit/cloudbender/test_regions_unit.py,sha256=9bvP268gpNyygjh1IEpSSiUt2aP6okv7QOsV1XoaIS0,6299
|
|
102
119
|
tests/unit/cloudbender/test_reservations_unit.py,sha256=ICuFT5sexnLvS7taoC18yQYuDZHpBRrNuCj3Uq_Arwo,5624
|
|
103
120
|
tests/unit/cloudbender/test_services_unit.py,sha256=iYaQpyCXDg77GQEIhmgiVwKX83jyvIf-4-4oya5WA_o,5043
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
121
|
+
tests/unit/projects/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
122
|
+
tests/unit/projects/test_project_data_connectors_unit.py,sha256=Yx2yCUgcuN_KfTKynZxse0Nx8jRrSlMygI7R8a-NjE4,3385
|
|
123
|
+
tests/unit/projects/test_project_datastores_unit.py,sha256=WZMKkhpEg2dcevJqT7k6QRcYJF6FJfq177BDk2GWOBk,3129
|
|
124
|
+
tests/unit/projects/test_project_keys_unit.py,sha256=n5Y2rKaenHA6JQFlViE1_dZ00FZ0PhM3C7rQtkuiRGM,3161
|
|
125
|
+
tests/unit/projects/test_project_secrets_unit.py,sha256=VE9L91FJodcwVGizfF65WYMiHZaF0s2AdW1aiJ3z7xA,3276
|
|
126
|
+
tests/unit/projects/test_project_services_unit.py,sha256=PzeNuJRuAG7RkrPWX0FfgFTt6-63FviecrDY06rLQ6A,3331
|
|
127
|
+
tests/unit/projects/test_projects_unit.py,sha256=lTGdKOCN2bjzGORhaDVVlnzJBuEItUDGN36MsyQjDo4,3823
|
|
128
|
+
proximl-0.5.9.dist-info/LICENSE,sha256=ADFxLEZDxKY0j4MdyUd5GNuhQ18rnWH5rOz1ZG7yiOA,1069
|
|
129
|
+
proximl-0.5.9.dist-info/METADATA,sha256=Gaq8RcfBkBF3J70Pf7Q60Sf6Fm2Yv91phU46RIinlqA,7344
|
|
130
|
+
proximl-0.5.9.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
|
131
|
+
proximl-0.5.9.dist-info/entry_points.txt,sha256=HmI311IIabkZReMCXu-nGbvIEW-KfaduAOyfiSqt5SY,63
|
|
132
|
+
proximl-0.5.9.dist-info/top_level.txt,sha256=-TWqc9tAaxmWmW4c7uYsmzPEYUIoh6z02xxqPbv7Kys,23
|
|
133
|
+
proximl-0.5.9.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import sys
|
|
3
|
+
import asyncio
|
|
4
|
+
from pytest import mark, fixture
|
|
5
|
+
|
|
6
|
+
pytestmark = [mark.sdk, mark.integration, mark.projects]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@mark.create
|
|
10
|
+
@mark.asyncio
|
|
11
|
+
class GetProjectsTests:
|
|
12
|
+
async def test_get_projects(self, proximl):
|
|
13
|
+
projects = await proximl.projects.list()
|
|
14
|
+
assert len(projects) > 0
|
|
15
|
+
|
|
16
|
+
async def test_get_project(self, proximl, project):
|
|
17
|
+
response = await proximl.projects.get(project.id)
|
|
18
|
+
assert response.id == project.id
|
|
19
|
+
|
|
20
|
+
async def test_project_properties(self, project):
|
|
21
|
+
assert isinstance(project.id, str)
|
|
22
|
+
assert isinstance(project.name, str)
|
|
23
|
+
assert isinstance(project.owner_name, str)
|
|
24
|
+
assert isinstance(project.is_owner, bool)
|
|
25
|
+
assert project.name == "New Project"
|
|
26
|
+
assert project.is_owner
|
|
27
|
+
|
|
28
|
+
async def test_project_str(self, project):
|
|
29
|
+
string = str(project)
|
|
30
|
+
regex = r"^{.*\"id\": \"" + project.id + r"\".*}$"
|
|
31
|
+
assert isinstance(string, str)
|
|
32
|
+
assert re.match(regex, string)
|
|
33
|
+
|
|
34
|
+
async def test_project_repr(self, project):
|
|
35
|
+
string = repr(project)
|
|
36
|
+
regex = r"^Project\( proximl , \*\*{.*'id': '" + project.id + r"'.*}\)$"
|
|
37
|
+
assert isinstance(string, str)
|
|
38
|
+
assert re.match(regex, string)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import sys
|
|
3
|
+
import asyncio
|
|
4
|
+
from pytest import mark, fixture
|
|
5
|
+
|
|
6
|
+
pytestmark = [mark.sdk, mark.integration, mark.projects]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@mark.create
|
|
10
|
+
@mark.asyncio
|
|
11
|
+
class ProjectKeysTests:
|
|
12
|
+
@fixture(scope="class")
|
|
13
|
+
async def project_key(self, project):
|
|
14
|
+
project_key = await project.keys.put(
|
|
15
|
+
type="aws", key_id="ASFHALKF", secret="IUHKLHKAHF"
|
|
16
|
+
)
|
|
17
|
+
yield project_key
|
|
18
|
+
await project.keys.remove(type="aws")
|
|
19
|
+
|
|
20
|
+
async def test_list_project_keys(self, project, project_key):
|
|
21
|
+
keys = await project.keys.list()
|
|
22
|
+
assert len(keys) > 0
|
|
23
|
+
|
|
24
|
+
async def test_project_key_properties(self, project, project_key):
|
|
25
|
+
assert isinstance(project_key.project_uuid, str)
|
|
26
|
+
assert isinstance(project_key.type, str)
|
|
27
|
+
assert isinstance(project_key.key_id, str)
|
|
28
|
+
assert project_key.type == "aws"
|
|
29
|
+
assert project.id == project_key.project_uuid
|
|
30
|
+
|
|
31
|
+
async def test_project_key_str(self, project_key):
|
|
32
|
+
string = str(project_key)
|
|
33
|
+
regex = r"^{.*\"type\": \"" + project_key.type + r"\".*}$"
|
|
34
|
+
assert isinstance(string, str)
|
|
35
|
+
assert re.match(regex, string)
|
|
36
|
+
|
|
37
|
+
async def test_project_key_repr(self, project_key):
|
|
38
|
+
string = repr(project_key)
|
|
39
|
+
regex = (
|
|
40
|
+
r"^ProjectKey\( proximl , \*\*{.*'type': '" + project_key.type + r"'.*}\)$"
|
|
41
|
+
)
|
|
42
|
+
assert isinstance(string, str)
|
|
43
|
+
assert re.match(regex, string)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import sys
|
|
3
|
+
import asyncio
|
|
4
|
+
from pytest import mark, fixture
|
|
5
|
+
|
|
6
|
+
pytestmark = [mark.sdk, mark.integration, mark.projects]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@mark.create
|
|
10
|
+
@mark.asyncio
|
|
11
|
+
class ProjectSecretsTests:
|
|
12
|
+
@fixture(scope="class")
|
|
13
|
+
async def project_secret(self, project):
|
|
14
|
+
project_secret = await project.secrets.put(
|
|
15
|
+
name="secret_value", value="IUHKLHKAHF"
|
|
16
|
+
)
|
|
17
|
+
yield project_secret
|
|
18
|
+
await project.secrets.remove(name="secret_value")
|
|
19
|
+
|
|
20
|
+
async def test_list_project_keys(self, project, project_secret):
|
|
21
|
+
secrets = await project.secrets.list()
|
|
22
|
+
assert len(secrets) > 0
|
|
23
|
+
|
|
24
|
+
async def test_project_secret_properties(self, project, project_secret):
|
|
25
|
+
assert isinstance(project_secret.project_uuid, str)
|
|
26
|
+
assert isinstance(project_secret.name, str)
|
|
27
|
+
assert project_secret.name == "secret_value"
|
|
28
|
+
assert project.id == project_secret.project_uuid
|
|
29
|
+
|
|
30
|
+
async def test_project_secret_str(self, project_secret):
|
|
31
|
+
string = str(project_secret)
|
|
32
|
+
regex = r"^{.*\"name\": \"" + project_secret.name + r"\".*}$"
|
|
33
|
+
assert isinstance(string, str)
|
|
34
|
+
assert re.match(regex, string)
|
|
35
|
+
|
|
36
|
+
async def test_project_secret_repr(self, project_secret):
|
|
37
|
+
string = repr(project_secret)
|
|
38
|
+
regex = (
|
|
39
|
+
r"^ProjectSecret\( proximl , \*\*{.*'name': '"
|
|
40
|
+
+ project_secret.name
|
|
41
|
+
+ r"'.*}\)$"
|
|
42
|
+
)
|
|
43
|
+
assert isinstance(string, str)
|
|
44
|
+
assert re.match(regex, string)
|
|
File without changes
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import json
|
|
3
|
+
import logging
|
|
4
|
+
from unittest.mock import AsyncMock, patch
|
|
5
|
+
from pytest import mark, fixture, raises
|
|
6
|
+
from aiohttp import WSMessage, WSMsgType
|
|
7
|
+
|
|
8
|
+
import proximl.projects.data_connectors as specimen
|
|
9
|
+
from proximl.exceptions import (
|
|
10
|
+
ApiError,
|
|
11
|
+
SpecificationError,
|
|
12
|
+
ProxiMLException,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
pytestmark = [mark.sdk, mark.unit, mark.projects]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@fixture
|
|
19
|
+
def project_data_connectors(mock_proximl):
|
|
20
|
+
yield specimen.ProjectDataConnectors(mock_proximl, project_id="1")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@fixture
|
|
24
|
+
def project_data_connector(mock_proximl):
|
|
25
|
+
yield specimen.ProjectDataConnector(
|
|
26
|
+
mock_proximl,
|
|
27
|
+
id="ds-id-1",
|
|
28
|
+
name="connector 1",
|
|
29
|
+
project_uuid="proj-id-1",
|
|
30
|
+
type="custom",
|
|
31
|
+
region_uuid="reg-id-1",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ProjectDataConnectorsTests:
|
|
36
|
+
@mark.asyncio
|
|
37
|
+
async def test_project_data_connectors_refresh(
|
|
38
|
+
self, project_data_connectors, mock_proximl
|
|
39
|
+
):
|
|
40
|
+
api_response = dict()
|
|
41
|
+
mock_proximl._query = AsyncMock(return_value=api_response)
|
|
42
|
+
await project_data_connectors.refresh()
|
|
43
|
+
mock_proximl._query.assert_called_once_with(
|
|
44
|
+
"/project/1/data_connectors", "PATCH"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
@mark.asyncio
|
|
48
|
+
async def test_project_data_connectors_list(
|
|
49
|
+
self, project_data_connectors, mock_proximl
|
|
50
|
+
):
|
|
51
|
+
api_response = [
|
|
52
|
+
{
|
|
53
|
+
"project_uuid": "proj-id-1",
|
|
54
|
+
"region_uuid": "reg-id-1",
|
|
55
|
+
"id": "store-id-1",
|
|
56
|
+
"type": "custom",
|
|
57
|
+
"name": "On-Prem Connection A",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"project_uuid": "proj-id-1",
|
|
61
|
+
"region_uuid": "reg-id-2",
|
|
62
|
+
"id": "store-id-2",
|
|
63
|
+
"type": "custom",
|
|
64
|
+
"name": "Cloud Connection B",
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
mock_proximl._query = AsyncMock(return_value=api_response)
|
|
68
|
+
resp = await project_data_connectors.list()
|
|
69
|
+
mock_proximl._query.assert_called_once_with(
|
|
70
|
+
"/project/1/data_connectors", "GET", dict()
|
|
71
|
+
)
|
|
72
|
+
assert len(resp) == 2
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ProjectDataConnectorTests:
|
|
76
|
+
def test_project_data_connector_properties(self, project_data_connector):
|
|
77
|
+
assert isinstance(project_data_connector.id, str)
|
|
78
|
+
assert isinstance(project_data_connector.name, str)
|
|
79
|
+
assert isinstance(project_data_connector.project_uuid, str)
|
|
80
|
+
assert isinstance(project_data_connector.type, str)
|
|
81
|
+
assert isinstance(project_data_connector.region_uuid, str)
|
|
82
|
+
|
|
83
|
+
def test_project_data_connector_str(self, project_data_connector):
|
|
84
|
+
string = str(project_data_connector)
|
|
85
|
+
regex = r"^{.*\"id\": \"" + project_data_connector.id + r"\".*}$"
|
|
86
|
+
assert isinstance(string, str)
|
|
87
|
+
assert re.match(regex, string)
|
|
88
|
+
|
|
89
|
+
def test_project_data_connector_repr(self, project_data_connector):
|
|
90
|
+
string = repr(project_data_connector)
|
|
91
|
+
regex = (
|
|
92
|
+
r"^ProjectDataConnector\( proximl , \*\*{.*'id': '"
|
|
93
|
+
+ project_data_connector.id
|
|
94
|
+
+ r"'.*}\)$"
|
|
95
|
+
)
|
|
96
|
+
assert isinstance(string, str)
|
|
97
|
+
assert re.match(regex, string)
|
|
98
|
+
|
|
99
|
+
def test_project_data_connector_bool(self, project_data_connector, mock_proximl):
|
|
100
|
+
empty_project_data_connector = specimen.ProjectDataConnector(mock_proximl)
|
|
101
|
+
assert bool(project_data_connector)
|
|
102
|
+
assert not bool(empty_project_data_connector)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import json
|
|
3
|
+
import logging
|
|
4
|
+
from unittest.mock import AsyncMock, patch
|
|
5
|
+
from pytest import mark, fixture, raises
|
|
6
|
+
from aiohttp import WSMessage, WSMsgType
|
|
7
|
+
|
|
8
|
+
import proximl.projects.datastores as specimen
|
|
9
|
+
from proximl.exceptions import (
|
|
10
|
+
ApiError,
|
|
11
|
+
SpecificationError,
|
|
12
|
+
ProxiMLException,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
pytestmark = [mark.sdk, mark.unit, mark.projects]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@fixture
|
|
19
|
+
def project_datastores(mock_proximl):
|
|
20
|
+
yield specimen.ProjectDatastores(mock_proximl, project_id="1")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@fixture
|
|
24
|
+
def project_datastore(mock_proximl):
|
|
25
|
+
yield specimen.ProjectDatastore(
|
|
26
|
+
mock_proximl,
|
|
27
|
+
id="ds-id-1",
|
|
28
|
+
name="datastore 1",
|
|
29
|
+
project_uuid="proj-id-1",
|
|
30
|
+
type="nfs",
|
|
31
|
+
region_uuid="reg-id-1",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ProjectDatastoresTests:
|
|
36
|
+
@mark.asyncio
|
|
37
|
+
async def test_project_datastores_refresh(self, project_datastores, mock_proximl):
|
|
38
|
+
api_response = dict()
|
|
39
|
+
mock_proximl._query = AsyncMock(return_value=api_response)
|
|
40
|
+
await project_datastores.refresh()
|
|
41
|
+
mock_proximl._query.assert_called_once_with("/project/1/datastores", "PATCH")
|
|
42
|
+
|
|
43
|
+
@mark.asyncio
|
|
44
|
+
async def test_project_datastores_list(self, project_datastores, mock_proximl):
|
|
45
|
+
api_response = [
|
|
46
|
+
{
|
|
47
|
+
"project_uuid": "proj-id-1",
|
|
48
|
+
"region_uuid": "reg-id-1",
|
|
49
|
+
"id": "store-id-1",
|
|
50
|
+
"type": "nfs",
|
|
51
|
+
"name": "On-prem NFS",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"project_uuid": "proj-id-1",
|
|
55
|
+
"region_uuid": "reg-id-2",
|
|
56
|
+
"id": "store-id-2",
|
|
57
|
+
"type": "smb",
|
|
58
|
+
"name": "GCP Samba",
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
mock_proximl._query = AsyncMock(return_value=api_response)
|
|
62
|
+
resp = await project_datastores.list()
|
|
63
|
+
mock_proximl._query.assert_called_once_with(
|
|
64
|
+
"/project/1/datastores", "GET", dict()
|
|
65
|
+
)
|
|
66
|
+
assert len(resp) == 2
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ProjectDatastoreTests:
|
|
70
|
+
def test_project_datastore_properties(self, project_datastore):
|
|
71
|
+
assert isinstance(project_datastore.id, str)
|
|
72
|
+
assert isinstance(project_datastore.name, str)
|
|
73
|
+
assert isinstance(project_datastore.project_uuid, str)
|
|
74
|
+
assert isinstance(project_datastore.type, str)
|
|
75
|
+
assert isinstance(project_datastore.region_uuid, str)
|
|
76
|
+
|
|
77
|
+
def test_project_datastore_str(self, project_datastore):
|
|
78
|
+
string = str(project_datastore)
|
|
79
|
+
regex = r"^{.*\"id\": \"" + project_datastore.id + r"\".*}$"
|
|
80
|
+
assert isinstance(string, str)
|
|
81
|
+
assert re.match(regex, string)
|
|
82
|
+
|
|
83
|
+
def test_project_datastore_repr(self, project_datastore):
|
|
84
|
+
string = repr(project_datastore)
|
|
85
|
+
regex = (
|
|
86
|
+
r"^ProjectDatastore\( proximl , \*\*{.*'id': '"
|
|
87
|
+
+ project_datastore.id
|
|
88
|
+
+ r"'.*}\)$"
|
|
89
|
+
)
|
|
90
|
+
assert isinstance(string, str)
|
|
91
|
+
assert re.match(regex, string)
|
|
92
|
+
|
|
93
|
+
def test_project_datastore_bool(self, project_datastore, mock_proximl):
|
|
94
|
+
empty_project_datastore = specimen.ProjectDatastore(mock_proximl)
|
|
95
|
+
assert bool(project_datastore)
|
|
96
|
+
assert not bool(empty_project_datastore)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import json
|
|
3
|
+
import logging
|
|
4
|
+
from unittest.mock import AsyncMock, patch
|
|
5
|
+
from pytest import mark, fixture, raises
|
|
6
|
+
from aiohttp import WSMessage, WSMsgType
|
|
7
|
+
|
|
8
|
+
import proximl.projects.keys as specimen
|
|
9
|
+
from proximl.exceptions import (
|
|
10
|
+
ApiError,
|
|
11
|
+
SpecificationError,
|
|
12
|
+
ProxiMLException,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
pytestmark = [mark.sdk, mark.unit, mark.projects]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@fixture
|
|
19
|
+
def project_keys(mock_proximl):
|
|
20
|
+
yield specimen.ProjectKeys(mock_proximl, project_id="1")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@fixture
|
|
24
|
+
def project_key(mock_proximl):
|
|
25
|
+
yield specimen.ProjectKey(
|
|
26
|
+
mock_proximl, project_uuid="proj-id-1", type="aws", key_id="AIYHGFSDLK"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ProjectKeysTests:
|
|
31
|
+
@mark.asyncio
|
|
32
|
+
async def test_project_keys_list(self, project_keys, mock_proximl):
|
|
33
|
+
api_response = [
|
|
34
|
+
{"project_uuid": "proj-id-1", "type": "aws", "key_id": "AIYHGFSDLK"},
|
|
35
|
+
{"project_uuid": "proj-id-1", "type": "gcp", "key_id": "credentials.json"},
|
|
36
|
+
]
|
|
37
|
+
mock_proximl._query = AsyncMock(return_value=api_response)
|
|
38
|
+
resp = await project_keys.list()
|
|
39
|
+
mock_proximl._query.assert_called_once_with("/project/1/keys", "GET", dict())
|
|
40
|
+
assert len(resp) == 2
|
|
41
|
+
|
|
42
|
+
@mark.asyncio
|
|
43
|
+
async def test_remove_project_key(
|
|
44
|
+
self,
|
|
45
|
+
project_keys,
|
|
46
|
+
mock_proximl,
|
|
47
|
+
):
|
|
48
|
+
api_response = dict()
|
|
49
|
+
mock_proximl._query = AsyncMock(return_value=api_response)
|
|
50
|
+
await project_keys.remove("aws")
|
|
51
|
+
mock_proximl._query.assert_called_once_with(
|
|
52
|
+
"/project/1/key/aws", "DELETE", dict()
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
@mark.asyncio
|
|
56
|
+
async def test_put_project_key(self, project_keys, mock_proximl):
|
|
57
|
+
requested_config = dict(type="aws", key_id="AIUDHADA", secret="ASKHJSLKF")
|
|
58
|
+
expected_payload = dict(key_id="AIUDHADA", secret="ASKHJSLKF")
|
|
59
|
+
api_response = {
|
|
60
|
+
"project_uuid": "project-id-1",
|
|
61
|
+
"type": "aws",
|
|
62
|
+
"key_id": "AIUDHADA",
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
mock_proximl._query = AsyncMock(return_value=api_response)
|
|
66
|
+
response = await project_keys.put(**requested_config)
|
|
67
|
+
mock_proximl._query.assert_called_once_with(
|
|
68
|
+
"/project/1/key/aws", "PUT", None, expected_payload
|
|
69
|
+
)
|
|
70
|
+
assert response.type == "aws"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class ProjectKeyTests:
|
|
74
|
+
def test_project_key_properties(self, project_key):
|
|
75
|
+
assert isinstance(project_key.type, str)
|
|
76
|
+
assert isinstance(project_key.key_id, str)
|
|
77
|
+
assert isinstance(project_key.project_uuid, str)
|
|
78
|
+
|
|
79
|
+
def test_project_key_str(self, project_key):
|
|
80
|
+
string = str(project_key)
|
|
81
|
+
regex = r"^{.*\"type\": \"" + project_key.type + r"\".*}$"
|
|
82
|
+
assert isinstance(string, str)
|
|
83
|
+
assert re.match(regex, string)
|
|
84
|
+
|
|
85
|
+
def test_project_key_repr(self, project_key):
|
|
86
|
+
string = repr(project_key)
|
|
87
|
+
regex = (
|
|
88
|
+
r"^ProjectKey\( proximl , \*\*{.*'type': '" + project_key.type + r"'.*}\)$"
|
|
89
|
+
)
|
|
90
|
+
assert isinstance(string, str)
|
|
91
|
+
assert re.match(regex, string)
|
|
92
|
+
|
|
93
|
+
def test_project_key_bool(self, project_key, mock_proximl):
|
|
94
|
+
empty_project_key = specimen.ProjectKey(mock_proximl)
|
|
95
|
+
assert bool(project_key)
|
|
96
|
+
assert not bool(empty_project_key)
|