nucliadb-utils 5.1.1.post1343__py3-none-any.whl → 5.1.1.post1349__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.
@@ -18,10 +18,16 @@
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
  #
20
20
  import os
21
+ from typing import Any, Type
22
+ from unittest.mock import Mock
21
23
 
22
24
  import pytest
23
25
  from pytest_lazy_fixtures import lazy_fixture
24
26
 
27
+ from nucliadb_utils.storages.azure import AzureStorage
28
+ from nucliadb_utils.storages.gcs import GCSStorage
29
+ from nucliadb_utils.storages.local import LocalStorage
30
+ from nucliadb_utils.storages.s3 import S3Storage
25
31
  from nucliadb_utils.utilities import Utility, clean_utility, set_utility
26
32
 
27
33
 
@@ -49,7 +55,7 @@ def get_testing_storage_backend(default="gcs"):
49
55
  return os.environ.get("TESTING_STORAGE_BACKEND", default)
50
56
 
51
57
 
52
- def lazy_storage_fixture(default="gcs"):
58
+ def lazy_storage_fixture():
53
59
  backend = get_testing_storage_backend()
54
60
  fixture_name = f"{backend}_storage"
55
61
  return [lazy_fixture.lf(fixture_name)]
@@ -66,3 +72,34 @@ async def storage(request):
66
72
  yield storage_driver
67
73
 
68
74
  clean_utility(Utility.STORAGE)
75
+
76
+
77
+ @pytest.fixture(scope="function")
78
+ def storage_settings(request, storage) -> dict[str, Any]:
79
+ """Useful fixture that returns the settings used in the generic `storage`
80
+ fixture.
81
+
82
+ This becomes useful when `storage` is overwritten programatically. Tests or
83
+ fixtures depending on generic storage settings can use this fixutre to get
84
+ the appropiate settings, being agnostic to the specific storage used.
85
+
86
+ """
87
+ if isinstance(storage, Mock):
88
+ yield {}
89
+ else:
90
+ storage_backend_map: dict[Type, str] = {
91
+ AzureStorage: "azure",
92
+ GCSStorage: "gcs",
93
+ LocalStorage: "local",
94
+ S3Storage: "s3",
95
+ }
96
+
97
+ backend = storage_backend_map.get(type(storage), None)
98
+ if backend is None:
99
+ raise Exception(f"Unknown storage configured ({type(storage)}), can't get settings")
100
+
101
+ fixture_name = f"{backend}_storage_settings"
102
+ # print("Using storage settings:", fixture_name)
103
+ assert fixture_name in request.fixturenames
104
+ settings: dict[str, Any] = request.getfixturevalue(fixture_name)
105
+ yield settings
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nucliadb_utils
3
- Version: 5.1.1.post1343
3
+ Version: 5.1.1.post1349
4
4
  Home-page: https://nuclia.com
5
5
  License: BSD
6
6
  Classifier: Development Status :: 4 - Beta
@@ -24,8 +24,8 @@ Requires-Dist: PyNaCl
24
24
  Requires-Dist: pyjwt>=2.4.0
25
25
  Requires-Dist: memorylru>=1.1.2
26
26
  Requires-Dist: mrflagly>=0.2.9
27
- Requires-Dist: nucliadb-protos>=5.1.1.post1343
28
- Requires-Dist: nucliadb-telemetry>=5.1.1.post1343
27
+ Requires-Dist: nucliadb-protos>=5.1.1.post1349
28
+ Requires-Dist: nucliadb-telemetry>=5.1.1.post1349
29
29
  Provides-Extra: cache
30
30
  Requires-Dist: redis>=4.3.4; extra == "cache"
31
31
  Requires-Dist: orjson>=3.6.7; extra == "cache"
@@ -58,14 +58,14 @@ nucliadb_utils/storages/utils.py,sha256=8g2rIwJeYIumQLOB47Yw1rx3twlhRB_cJxer65Qf
58
58
  nucliadb_utils/tests/__init__.py,sha256=Oo9CAE7B0eW5VHn8sHd6o30SQzOWUhktLPRXdlDOleA,1456
59
59
  nucliadb_utils/tests/asyncbenchmark.py,sha256=x4be2IwCawle9zWgMOJkmwoUwk5p1tv7cLQGmybkEOg,10587
60
60
  nucliadb_utils/tests/azure.py,sha256=Dg-Eb4KVScG-O6P9y-bVQZTAKTNUMQ0i-CKEd9IdrWw,4474
61
- nucliadb_utils/tests/fixtures.py,sha256=b-e6Ciewh7GSh9rriG01bN9GiMW6xbGgrp3KiX7HNiY,2089
61
+ nucliadb_utils/tests/fixtures.py,sha256=i0sqPqe5a5JlKGFdaIvOlHYkZ3pHZ2hTIgTsaIB3vSM,3472
62
62
  nucliadb_utils/tests/gcs.py,sha256=Bx-kxf2NoYYeyNFPpBFxbRN8kIiYFpELEvqG0V1_9Ks,4183
63
63
  nucliadb_utils/tests/indexing.py,sha256=YW2QhkhO9Q_8A4kKWJaWSvXvyQ_AiAwY1VylcfVQFxk,1513
64
64
  nucliadb_utils/tests/local.py,sha256=7nuP8EFUAiA8ZH50R1iPV9EUXBySQxOanVm3Zht_e0g,1835
65
65
  nucliadb_utils/tests/nats.py,sha256=xqpww4jZjTKY9oPGlJdDJG67L3FIBQsa9qDHxILR8r8,7687
66
66
  nucliadb_utils/tests/s3.py,sha256=IdMxK_cNdSHLvO1u8BwsKFzD87Hk1MVPDZ57zx6h-rA,3656
67
- nucliadb_utils-5.1.1.post1343.dist-info/METADATA,sha256=f7IKZ1pSojpApZqrBFPEXIxgOmxrANVUxI2x5lyn9uw,2071
68
- nucliadb_utils-5.1.1.post1343.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
69
- nucliadb_utils-5.1.1.post1343.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
70
- nucliadb_utils-5.1.1.post1343.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
71
- nucliadb_utils-5.1.1.post1343.dist-info/RECORD,,
67
+ nucliadb_utils-5.1.1.post1349.dist-info/METADATA,sha256=TuyUdvQXJwsaPpjCRbEDs9GKx63vIyzgplZMztcTAZk,2071
68
+ nucliadb_utils-5.1.1.post1349.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
69
+ nucliadb_utils-5.1.1.post1349.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
70
+ nucliadb_utils-5.1.1.post1349.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
71
+ nucliadb_utils-5.1.1.post1349.dist-info/RECORD,,