splight-lib 5.6.5.dev0__tar.gz → 5.7.0__tar.gz

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.
Files changed (95) hide show
  1. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/PKG-INFO +1 -1
  2. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/pyproject.toml +1 -1
  3. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/database/classmap.py +3 -1
  4. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/database/remote_client.py +21 -11
  5. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/exceptions.py +8 -0
  6. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/tests/test_database.py +5 -0
  7. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/tests/test_datalake.py +4 -0
  8. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/__init__.py +2 -1
  9. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/asset.py +30 -2
  10. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/base.py +2 -2
  11. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/exceptions.py +4 -0
  12. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/hub_solution.py +10 -1
  13. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/tests/test_database_model.py +52 -26
  14. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/LICENSE.txt +0 -0
  15. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/README.md +0 -0
  16. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/__init__.py +0 -0
  17. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/abstract/__init__.py +0 -0
  18. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/abstract/client.py +0 -0
  19. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/auth/__init__.py +0 -0
  20. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/auth/exceptions.py +0 -0
  21. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/auth/mac_auth.py +0 -0
  22. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/auth/token.py +0 -0
  23. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/__init__.py +0 -0
  24. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/database/__init__.py +0 -0
  25. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/database/abstract.py +0 -0
  26. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/database/builder.py +0 -0
  27. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/database/local_client.py +0 -0
  28. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/datalake/__init__.py +0 -0
  29. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/datalake/abstract.py +0 -0
  30. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/datalake/buffer.py +0 -0
  31. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/datalake/builder.py +0 -0
  32. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/datalake/exceptions.py +0 -0
  33. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/datalake/local_client.py +0 -0
  34. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/datalake/remote_client.py +0 -0
  35. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/datalake/schemas.py +0 -0
  36. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/file_handler.py +0 -0
  37. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/filter.py +0 -0
  38. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/hub/__init__.py +0 -0
  39. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/hub/abstract.py +0 -0
  40. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/client/hub/client.py +0 -0
  41. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/component/__init__.py +0 -0
  42. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/component/abstract.py +0 -0
  43. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/component/exceptions.py +0 -0
  44. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/component/spec.py +0 -0
  45. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/component/tests/test_abstract.py +0 -0
  46. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/component/tests/test_spec.py +0 -0
  47. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/constants.py +0 -0
  48. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/encryption.py +0 -0
  49. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/execution/__init__.py +0 -0
  50. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/execution/engine.py +0 -0
  51. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/execution/exceptions.py +0 -0
  52. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/execution/scheduling.py +0 -0
  53. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/execution/task.py +0 -0
  54. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/execution/tests/test_execution.py +0 -0
  55. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/execution/tests/test_scheduling.py +0 -0
  56. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/execution/trigger.py +0 -0
  57. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/logging/__init__.py +0 -0
  58. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/logging/_internal.py +0 -0
  59. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/logging/component.py +0 -0
  60. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/logging/constants.py +0 -0
  61. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/logging/logging.py +0 -0
  62. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/logging/tests/test_logging.py +0 -0
  63. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/alert.py +0 -0
  64. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/attribute.py +0 -0
  65. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/component.py +0 -0
  66. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/dashboard.py +0 -0
  67. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/data_address.py +0 -0
  68. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/file.py +0 -0
  69. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/function.py +0 -0
  70. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/generic.py +0 -0
  71. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/hub.py +0 -0
  72. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/metadata.py +0 -0
  73. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/native.py +0 -0
  74. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/pipeline.py +0 -0
  75. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/secret.py +0 -0
  76. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/tests/models.json +0 -0
  77. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/tests/test_component_object_instance.py +0 -0
  78. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/tests/test_metadata.py +0 -0
  79. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/models/tests/test_models.py +0 -0
  80. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/restclient/__init__.py +0 -0
  81. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/restclient/client.py +0 -0
  82. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/restclient/exceptions.py +0 -0
  83. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/restclient/tests/test_restclient.py +0 -0
  84. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/restclient/types.py +0 -0
  85. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/settings.py +0 -0
  86. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/stringcase.py +0 -0
  87. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/testing/__init__.py +0 -0
  88. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/tests/FakeProc.py +0 -0
  89. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/tests/asset_geometries.json +0 -0
  90. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/tests/test_api_contracts.py +0 -0
  91. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/tests/test_encryption.py +0 -0
  92. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/utils/__init__.py +0 -0
  93. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/utils/custom_model.py +0 -0
  94. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/utils/hub.py +0 -0
  95. {splight_lib-5.6.5.dev0 → splight_lib-5.7.0}/splight_lib/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: splight-lib
3
- Version: 5.6.5.dev0
3
+ Version: 5.7.0
4
4
  Summary: Splight Library
5
5
  Author: Splight Dev
6
6
  Author-email: dev@splight-ae.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "splight-lib"
3
- version = "5.6.5dev0"
3
+ version = "5.7.0"
4
4
  description = "Splight Library"
5
5
  authors = ["Splight Dev <dev@splight-ae.com>"]
6
6
  readme = "README.md"
@@ -3,7 +3,9 @@ from splight_lib.constants import ENGINE_PREFIX, HUB_PREFIX
3
3
  MODEL_NAME_MAP = {
4
4
  "advancedfilter": f"{ENGINE_PREFIX}/alert/advancedfilters/",
5
5
  "alert": f"{ENGINE_PREFIX}/alert/alerts/",
6
- "asset": f"{ENGINE_PREFIX}/assets/",
6
+ "asset": f"{ENGINE_PREFIX}/asset/assets/",
7
+ "assetkind": f"{ENGINE_PREFIX}/asset/kinds/",
8
+ # TODO: update to new endpoint for attributes
7
9
  "attribute": f"{ENGINE_PREFIX}/attributes/",
8
10
  "metadata": f"{ENGINE_PREFIX}/metadata/",
9
11
  "chart": f"{ENGINE_PREFIX}/dashboard/charts/",
@@ -20,6 +20,7 @@ from splight_lib.client.exceptions import (
20
20
  InstanceNotFound,
21
21
  InvalidModel,
22
22
  InvalidModelName,
23
+ RequestError,
23
24
  )
24
25
  from splight_lib.constants import ENGINE_PREFIX
25
26
  from splight_lib.logging._internal import LogTags, get_splight_logger
@@ -116,7 +117,8 @@ class RemoteDatabaseClient(AbstractDatabaseClient, AbstractRemoteClient):
116
117
  api_path = self._get_api_path(resource_name)
117
118
  url = self._base_url / api_path / f"{id}/"
118
119
  response = self._restclient.delete(url)
119
- response.raise_for_status()
120
+ if response.is_error:
121
+ raise RequestError(response.status_code, response.text)
120
122
 
121
123
  @retry(SPLIGHT_REQUEST_EXCEPTIONS, tries=3, delay=1)
122
124
  def _get(
@@ -155,7 +157,8 @@ class RemoteDatabaseClient(AbstractDatabaseClient, AbstractRemoteClient):
155
157
  api_path = api_path.format_map({"prefix": ENGINE_PREFIX, **instance})
156
158
  url = self._base_url / api_path
157
159
  response = self._restclient.post(url, json=instance)
158
- response.raise_for_status()
160
+ if response.is_error:
161
+ raise RequestError(response.status_code, response.text)
159
162
  return response.json()
160
163
 
161
164
  def _retrieve_multiple(
@@ -180,8 +183,8 @@ class RemoteDatabaseClient(AbstractDatabaseClient, AbstractRemoteClient):
180
183
  response = self._restclient.get(url)
181
184
  if response.status_code == codes.NOT_FOUND:
182
185
  raise InstanceNotFound(resource_name, id)
183
- else:
184
- response.raise_for_status()
186
+ elif response.is_error:
187
+ raise RequestError(response.status_code, response.text)
185
188
  return response.json()
186
189
 
187
190
  @retry(SPLIGHT_REQUEST_EXCEPTIONS, tries=3, delay=1)
@@ -214,7 +217,8 @@ class RemoteDatabaseClient(AbstractDatabaseClient, AbstractRemoteClient):
214
217
  resource_id = instance.get("id")
215
218
  url = self._base_url / api_path / f"{resource_id}/download_url/"
216
219
  response = self._restclient.get(url)
217
- response.raise_for_status()
220
+ if response.is_error:
221
+ raise RequestError(response.status_code, response.text)
218
222
  download_url = response.json().get("url")
219
223
 
220
224
  file = NamedTemporaryFile(mode="wb+", suffix=instance["name"])
@@ -253,7 +257,8 @@ class RemoteDatabaseClient(AbstractDatabaseClient, AbstractRemoteClient):
253
257
  def _list(self, url: furl, **kwargs) -> PaginatedResponse:
254
258
  params = self._parse_params(**kwargs)
255
259
  response = self._restclient.get(url, params=params)
256
- response.raise_for_status()
260
+ if response.is_error:
261
+ raise RequestError(response.status_code, response.text)
257
262
  return response.json()
258
263
 
259
264
  def _create(
@@ -281,7 +286,8 @@ class RemoteDatabaseClient(AbstractDatabaseClient, AbstractRemoteClient):
281
286
  req_args = {"json": instance}
282
287
 
283
288
  response = self._restclient.post(url, **req_args)
284
- response.raise_for_status()
289
+ if response.is_error:
290
+ raise RequestError(response.status_code, response.text)
285
291
  instance = response.json()
286
292
  logger.debug(
287
293
  "Instance %s created", instance["id"], tags=LogTags.DATABASE
@@ -318,12 +324,14 @@ class RemoteDatabaseClient(AbstractDatabaseClient, AbstractRemoteClient):
318
324
 
319
325
  response = self._restclient.put(url, **req_args)
320
326
 
321
- response.raise_for_status()
327
+ if response.is_error:
328
+ raise RequestError(response.status_code, response.text)
322
329
  return response.json()
323
330
 
324
331
  def _create_file(self, instance: Dict, url: furl):
325
332
  response = self._restclient.post(url, data=instance)
326
- response.raise_for_status()
333
+ if response.is_error:
334
+ raise RequestError(response.status_code, response.text)
327
335
  file_path = instance["file"]
328
336
  # Check is this is handled somewher
329
337
  created_instance = response.json()
@@ -335,7 +343,8 @@ class RemoteDatabaseClient(AbstractDatabaseClient, AbstractRemoteClient):
335
343
  resource_id = instance.get("id")
336
344
  url = self._base_url / api_path / f"{resource_id}/upload_url/"
337
345
  response = self._restclient.get(url)
338
- response.raise_for_status()
346
+ if response.is_error:
347
+ raise RequestError(response.status_code, response.text)
339
348
  upload_url = response.json().get("url")
340
349
  file = open(file_path, "rb")
341
350
  file_name = instance["name"]
@@ -345,7 +354,8 @@ class RemoteDatabaseClient(AbstractDatabaseClient, AbstractRemoteClient):
345
354
  upload_url,
346
355
  files=file,
347
356
  )
348
- response.raise_for_status()
357
+ if response.is_error:
358
+ raise RequestError(response.status_code, response.text)
349
359
  logger.debug(
350
360
  "File uploaded succesfully %s.", resource_id, tags=LogTags.DATABASE
351
361
  )
@@ -16,6 +16,14 @@ SPLIGHT_REQUEST_EXCEPTIONS = (
16
16
  )
17
17
 
18
18
 
19
+ class RequestError(Exception):
20
+ def __init__(self, status_code: int, text: str):
21
+ self._msg = f"Got an error status code: {status_code} - {text}"
22
+
23
+ def __str__(self) -> str:
24
+ return self._msg
25
+
26
+
19
27
  class InvalidModelName(Exception):
20
28
  def __init__(self, model_name: str):
21
29
  self._msg = f"Model {model_name} is not a valid database model"
@@ -21,6 +21,10 @@ class MockResponse:
21
21
  def __init__(self, json_data):
22
22
  self.json_data = json_data
23
23
 
24
+ @property
25
+ def is_error(self) -> bool:
26
+ return False if self.status_code < 400 else True
27
+
24
28
  def raise_for_status(self):
25
29
  return None
26
30
 
@@ -115,6 +119,7 @@ def test_delete(mocker: MockerFixture):
115
119
  mock_delete = mocker.patch.object(
116
120
  SplightRestClient,
117
121
  "delete",
122
+ return_value=MockResponse({}),
118
123
  )
119
124
  client.delete("alert", "instance_id")
120
125
  mock_delete.assert_called_once()
@@ -18,6 +18,10 @@ class MockResponse:
18
18
  def __init__(self, json_data):
19
19
  self.json_data = json_data
20
20
 
21
+ @property
22
+ def is_error(self) -> bool:
23
+ return False if self.status_code < 400 else True
24
+
21
25
  def raise_for_status(self):
22
26
  return None
23
27
 
@@ -1,5 +1,5 @@
1
1
  from splight_lib.models.alert import Alert, AlertItem
2
- from splight_lib.models.asset import Asset
2
+ from splight_lib.models.asset import Asset, AssetKind
3
3
  from splight_lib.models.attribute import Attribute
4
4
  from splight_lib.models.component import (
5
5
  Component,
@@ -30,6 +30,7 @@ __all__ = [
30
30
  Alert,
31
31
  AlertItem,
32
32
  Asset,
33
+ AssetKind,
33
34
  Attribute,
34
35
  Boolean,
35
36
  Chart,
@@ -2,16 +2,42 @@ import warnings
2
2
  from typing import Any, List, Optional, Tuple
3
3
 
4
4
  from geojson_pydantic import GeometryCollection
5
- from pydantic import Field
5
+ from pydantic import BaseModel, Field
6
6
 
7
7
  from splight_lib.constants import DESCRIPTION_MAX_LENGTH
8
8
  from splight_lib.models.attribute import Attribute
9
9
  from splight_lib.models.base import SplightDatabaseBaseModel
10
+ from splight_lib.models.exceptions import MethodNotAllowed
10
11
  from splight_lib.models.metadata import Metadata
11
12
 
12
13
  warnings.filterwarnings("ignore", category=UserWarning)
13
14
 
14
15
 
16
+ class AssetRepr(BaseModel):
17
+ id: str
18
+ name: str
19
+
20
+
21
+ class AssetRelationship(BaseModel):
22
+ id: str
23
+ name: str
24
+ description: Optional[str] = None
25
+ related_asset_kind: Optional[str] = None
26
+ asset: AssetRepr
27
+ related_asset: AssetRepr
28
+
29
+
30
+ class AssetKind(SplightDatabaseBaseModel):
31
+ id: Optional[str] = None
32
+ name: str
33
+
34
+ def save(self):
35
+ raise MethodNotAllowed("AssetKind objects are read-only")
36
+
37
+ def delete(self):
38
+ raise MethodNotAllowed("AssetKind objects are read-only")
39
+
40
+
15
41
  class Asset(SplightDatabaseBaseModel):
16
42
  id: Optional[str] = None
17
43
  name: str
@@ -23,7 +49,9 @@ class Asset(SplightDatabaseBaseModel):
23
49
  metadata: List[Metadata] = []
24
50
  geometry: Optional[GeometryCollection] = None
25
51
  centroid_coordinates: Optional[Tuple[float, float]] = None
26
- related_assets: Optional[List["Asset"]] = []
52
+ kind: Optional[AssetKind] = None
53
+ related_to: List[AssetRelationship] = []
54
+ related_from: List[AssetRelationship] = []
27
55
 
28
56
  def set_attribute(self, attribute: Attribute, value: Any, value_type: str):
29
57
  new_value = self._db_client.operate(
@@ -41,8 +41,8 @@ class SplightDatabaseBaseModel(BaseModel):
41
41
  self.model_dump(exclude_none=True, mode="json"),
42
42
  files=files_dict,
43
43
  )
44
- if not self.id:
45
- self.id = saved["id"]
44
+ for field in self.model_fields:
45
+ setattr(self, field, saved.get(field))
46
46
 
47
47
  def delete(self):
48
48
  self._db_client.delete(
@@ -1,3 +1,7 @@
1
+ class MethodNotAllowed(Exception):
2
+ pass
3
+
4
+
1
5
  class InvalidObjectInstance(Exception):
2
6
  pass
3
7
 
@@ -18,9 +18,17 @@ class HubSolution(SplightDatabaseBaseModel):
18
18
  main_file: Optional[FilePath] = Field(default=None, exclude=True)
19
19
  variables_file: Optional[FilePath] = Field(default=None, exclude=True)
20
20
  values_file: Optional[FilePath] = Field(default=None, exclude=True)
21
+ readme_file: Optional[FilePath] = Field(default=None, exclude=True)
21
22
 
22
23
  def save(self) -> None:
23
- if not all([self.main_file, self.variables_file, self.values_file]):
24
+ if not all(
25
+ [
26
+ self.main_file,
27
+ self.variables_file,
28
+ self.values_file,
29
+ self.readme_file,
30
+ ]
31
+ ):
24
32
  raise ValueError("Missing one of the required files")
25
33
  return super().save()
26
34
 
@@ -29,4 +37,5 @@ class HubSolution(SplightDatabaseBaseModel):
29
37
  "main_file": self.main_file,
30
38
  "variables_file": self.variables_file,
31
39
  "values_file": self.values_file,
40
+ "readme_file": self.readme_file,
32
41
  }
@@ -9,8 +9,8 @@ from uuid import uuid4 # noqa: E402
9
9
 
10
10
  import pytest # noqa: E402
11
11
 
12
- from splight_lib.client.database.local_client import ( # noqa: E402
13
- LocalDatabaseClient,
12
+ from splight_lib.client.database.remote_client import ( # noqa: E402
13
+ RemoteDatabaseClient,
14
14
  )
15
15
  from splight_lib.models.base import SplightDatabaseBaseModel # noqa: E402
16
16
  from splight_lib.settings import settings # noqa: E402
@@ -53,7 +53,7 @@ RESOURCE_LIST = [
53
53
  ]
54
54
 
55
55
 
56
- @patch.object(LocalDatabaseClient, "_get", return_value=RESOURCE_LIST)
56
+ @patch.object(RemoteDatabaseClient, "_get", return_value=RESOURCE_LIST)
57
57
  def test_list(mock):
58
58
  instances = Resource.list()
59
59
  mock.assert_called_with(Resource.__name__)
@@ -64,7 +64,7 @@ def test_list(mock):
64
64
  )
65
65
 
66
66
 
67
- @patch.object(LocalDatabaseClient, "_get", return_value=RESOURCE_LIST)
67
+ @patch.object(RemoteDatabaseClient, "_get", return_value=RESOURCE_LIST)
68
68
  def test_list_first(mock):
69
69
  instances = Resource.list(first=True)
70
70
  mock.assert_called_with(Resource.__name__, first=True)
@@ -81,11 +81,18 @@ def test_list_first(mock):
81
81
  )
82
82
  def test_retrieve(instance_dict):
83
83
  with patch.object(
84
- LocalDatabaseClient, "_get", return_value=instance_dict
84
+ RemoteDatabaseClient, "_get", return_value=instance_dict
85
85
  ) as mock:
86
- instance = Resource.retrieve(instance_dict["id"])
87
- mock.assert_called_with(Resource.__name__, id=instance.id, first=True)
88
- assert instance.model_dump() == instance_dict
86
+ with patch.object(
87
+ RemoteDatabaseClient,
88
+ "_get_api_path",
89
+ return_value="/api/resource/",
90
+ ):
91
+ instance = Resource.retrieve(instance_dict["id"])
92
+ mock.assert_called_with(
93
+ Resource.__name__, id=instance.id, first=True
94
+ )
95
+ assert instance.model_dump() == instance_dict
89
96
 
90
97
 
91
98
  @pytest.mark.parametrize(
@@ -94,12 +101,19 @@ def test_retrieve(instance_dict):
94
101
  )
95
102
  def test_save_with_id(instance_dict):
96
103
  with patch.object(
97
- LocalDatabaseClient, "save", return_value=instance_dict
104
+ RemoteDatabaseClient, "save", return_value=instance_dict
98
105
  ) as mock:
99
- resource = Resource.model_validate(instance_dict)
100
- resource.save()
101
- mock.assert_called_with(Resource.__name__, instance_dict, files=None)
102
- assert resource.model_dump() == instance_dict
106
+ with patch.object(
107
+ RemoteDatabaseClient,
108
+ "_get_api_path",
109
+ return_value="/api/resource/",
110
+ ):
111
+ resource = Resource.model_validate(instance_dict)
112
+ resource.save()
113
+ mock.assert_called_with(
114
+ Resource.__name__, instance_dict, files=None
115
+ )
116
+ assert resource.model_dump() == instance_dict
103
117
 
104
118
 
105
119
  @pytest.mark.parametrize(
@@ -108,14 +122,21 @@ def test_save_with_id(instance_dict):
108
122
  )
109
123
  def test_save_without_id(instance_dict):
110
124
  with patch.object(
111
- LocalDatabaseClient, "save", return_value=instance_dict
125
+ RemoteDatabaseClient, "save", return_value=instance_dict
112
126
  ) as mock:
113
- resource = Resource.model_validate(instance_dict)
114
- resource.id = None
115
- resource_dict = resource.model_dump(exclude_none=True)
116
- resource.save()
117
- mock.assert_called_with(Resource.__name__, resource_dict, files=None)
118
- assert resource.model_dump() == instance_dict
127
+ with patch.object(
128
+ RemoteDatabaseClient,
129
+ "_get_api_path",
130
+ return_value="/api/resource/",
131
+ ):
132
+ resource = Resource.model_validate(instance_dict)
133
+ resource.id = None
134
+ resource_dict = resource.model_dump(exclude_none=True)
135
+ resource.save()
136
+ mock.assert_called_with(
137
+ Resource.__name__, resource_dict, files=None
138
+ )
139
+ assert resource.model_dump() == instance_dict
119
140
 
120
141
 
121
142
  @pytest.mark.parametrize(
@@ -124,10 +145,15 @@ def test_save_without_id(instance_dict):
124
145
  )
125
146
  def test_delete(instance_dict):
126
147
  with patch.object(
127
- LocalDatabaseClient, "delete", return_value=None
148
+ RemoteDatabaseClient, "delete", return_value=instance_dict
128
149
  ) as mock:
129
- resource = Resource.model_validate(instance_dict)
130
- resource.delete()
131
- mock.assert_called_with(
132
- resource_name=Resource.__name__, id=resource.id
133
- )
150
+ with patch.object(
151
+ RemoteDatabaseClient,
152
+ "_get_api_path",
153
+ return_value="/api/resource/",
154
+ ):
155
+ resource = Resource.model_validate(instance_dict)
156
+ resource.delete()
157
+ mock.assert_called_with(
158
+ resource_name=Resource.__name__, id=resource.id
159
+ )
File without changes