nucliadb-utils 4.0.3.post573__py3-none-any.whl → 4.0.3.post576__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.
- nucliadb_utils/tests/{conftest.py → fixtures.py} +1 -9
- {nucliadb_utils-4.0.3.post573.dist-info → nucliadb_utils-4.0.3.post576.dist-info}/METADATA +3 -3
- {nucliadb_utils-4.0.3.post573.dist-info → nucliadb_utils-4.0.3.post576.dist-info}/RECORD +6 -21
- nucliadb_utils/tests/unit/__init__.py +0 -18
- nucliadb_utils/tests/unit/storages/__init__.py +0 -18
- nucliadb_utils/tests/unit/storages/test_aws.py +0 -60
- nucliadb_utils/tests/unit/storages/test_gcs.py +0 -119
- nucliadb_utils/tests/unit/storages/test_pg.py +0 -561
- nucliadb_utils/tests/unit/storages/test_storage.py +0 -228
- nucliadb_utils/tests/unit/test_asyncio_utils.py +0 -72
- nucliadb_utils/tests/unit/test_authentication.py +0 -159
- nucliadb_utils/tests/unit/test_helpers.py +0 -45
- nucliadb_utils/tests/unit/test_nats.py +0 -154
- nucliadb_utils/tests/unit/test_run.py +0 -57
- nucliadb_utils/tests/unit/test_signals.py +0 -81
- nucliadb_utils/tests/unit/test_tests.py +0 -27
- nucliadb_utils/tests/unit/test_transaction.py +0 -119
- nucliadb_utils/tests/unit/test_utilities.py +0 -173
- {nucliadb_utils-4.0.3.post573.dist-info → nucliadb_utils-4.0.3.post576.dist-info}/WHEEL +0 -0
- {nucliadb_utils-4.0.3.post573.dist-info → nucliadb_utils-4.0.3.post576.dist-info}/top_level.txt +0 -0
- {nucliadb_utils-4.0.3.post573.dist-info → nucliadb_utils-4.0.3.post576.dist-info}/zip-safe +0 -0
@@ -16,20 +16,12 @@
|
|
16
16
|
#
|
17
17
|
# You should have received a copy of the GNU Affero General Public License
|
18
18
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
19
20
|
import os
|
20
21
|
|
21
22
|
import pytest
|
22
23
|
from pytest_lazy_fixtures import lazy_fixture
|
23
24
|
|
24
|
-
pytest_plugins = [
|
25
|
-
"pytest_docker_fixtures",
|
26
|
-
"nucliadb_utils.tests.gcs",
|
27
|
-
"nucliadb_utils.tests.nats",
|
28
|
-
"nucliadb_utils.tests.s3",
|
29
|
-
"nucliadb_utils.tests.pg",
|
30
|
-
"nucliadb_utils.tests.local",
|
31
|
-
]
|
32
|
-
|
33
25
|
|
34
26
|
def get_testing_storage_backend(default="gcs"):
|
35
27
|
return os.environ.get("TESTING_STORAGE_BACKEND", default)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nucliadb_utils
|
3
|
-
Version: 4.0.3.
|
3
|
+
Version: 4.0.3.post576
|
4
4
|
Home-page: https://nuclia.com
|
5
5
|
License: BSD
|
6
6
|
Classifier: Development Status :: 4 - Beta
|
@@ -23,8 +23,8 @@ Requires-Dist: PyNaCl
|
|
23
23
|
Requires-Dist: pyjwt >=2.4.0
|
24
24
|
Requires-Dist: memorylru >=1.1.2
|
25
25
|
Requires-Dist: mrflagly
|
26
|
-
Requires-Dist: nucliadb-protos >=4.0.3.
|
27
|
-
Requires-Dist: nucliadb-telemetry >=4.0.3.
|
26
|
+
Requires-Dist: nucliadb-protos >=4.0.3.post576
|
27
|
+
Requires-Dist: nucliadb-telemetry >=4.0.3.post576
|
28
28
|
Provides-Extra: cache
|
29
29
|
Requires-Dist: redis >=4.3.4 ; extra == 'cache'
|
30
30
|
Requires-Dist: orjson >=3.6.7 ; extra == 'cache'
|
@@ -49,30 +49,15 @@ nucliadb_utils/storages/settings.py,sha256=ugCPy1zxBOmA2KosT-4tsjpvP002kg5iQyi42
|
|
49
49
|
nucliadb_utils/storages/storage.py,sha256=sR2Qvev6eLUvbH1WTXjqXIOnKRy1YMMx6Vsj0wZ2x8A,20585
|
50
50
|
nucliadb_utils/tests/__init__.py,sha256=Oo9CAE7B0eW5VHn8sHd6o30SQzOWUhktLPRXdlDOleA,1456
|
51
51
|
nucliadb_utils/tests/asyncbenchmark.py,sha256=rN_NNDk4ras0qgFp0QlRyAi9ZU9xITdzxl2s5CigzBo,10698
|
52
|
-
nucliadb_utils/tests/
|
52
|
+
nucliadb_utils/tests/fixtures.py,sha256=ZvKaxZFMULC2Sbo0jSIuGxJW_cgVH_pNjhVYo9PbgyA,1665
|
53
53
|
nucliadb_utils/tests/gcs.py,sha256=1dbt_zG3uZPZDF3Nyrgrvi_bsKmafAUOm4Pu4bzt7wI,3098
|
54
54
|
nucliadb_utils/tests/indexing.py,sha256=YW2QhkhO9Q_8A4kKWJaWSvXvyQ_AiAwY1VylcfVQFxk,1513
|
55
55
|
nucliadb_utils/tests/local.py,sha256=c3gZJJWmvOftruJkIQIwB3q_hh3uxEhqGIAVWim1Bbk,1343
|
56
56
|
nucliadb_utils/tests/nats.py,sha256=lgRe6YH9LSoI7XgcyKAC2VTSAtuu8EeMve0jWWC_kOY,7701
|
57
57
|
nucliadb_utils/tests/pg.py,sha256=HBpvaNDs9T_L55tvJCJTPnsCDrB8ehI_9HRYz6SPWNE,1819
|
58
58
|
nucliadb_utils/tests/s3.py,sha256=YB8QqDaBXxyhHonEHmeBbRRDmvB7sTOaKBSi8KBGokg,2330
|
59
|
-
nucliadb_utils/
|
60
|
-
nucliadb_utils/
|
61
|
-
nucliadb_utils/
|
62
|
-
nucliadb_utils/
|
63
|
-
nucliadb_utils/
|
64
|
-
nucliadb_utils/tests/unit/test_run.py,sha256=VHeojVBj_AfV_uNch9eEi4zCT-O94VKjwb_O-UZgqpA,1910
|
65
|
-
nucliadb_utils/tests/unit/test_signals.py,sha256=Br3BjBZpAtKPqeSmfHSGf1Seu4mB2OBWFCgLcNEH0PQ,2647
|
66
|
-
nucliadb_utils/tests/unit/test_tests.py,sha256=-YHgVMKJr_3WYwrBj9TnwpVLIkP80PLZpWnvAIYvnz8,1189
|
67
|
-
nucliadb_utils/tests/unit/test_transaction.py,sha256=ULVALWbMWEkH2Gq5Q8olEL8k8Kqyh5RAe0Lp9qdF1V4,3917
|
68
|
-
nucliadb_utils/tests/unit/test_utilities.py,sha256=KcHSPp3RZyKAnscJrIwc2M3PCD3l1DWb6WuqtI6cl5o,5377
|
69
|
-
nucliadb_utils/tests/unit/storages/__init__.py,sha256=itSI7dtTwFP55YMX4iK7JzdMHS5CQVUiB1XzQu4UBh8,833
|
70
|
-
nucliadb_utils/tests/unit/storages/test_aws.py,sha256=GCsB_jwCUNV3Ogt8TZZEmNKAHvOlR0HGU7blrFbtJqs,1924
|
71
|
-
nucliadb_utils/tests/unit/storages/test_gcs.py,sha256=2XzJwgNpfjVGjtE-QdZhu3ayuT1EMEXINdM-_SatPCY,3554
|
72
|
-
nucliadb_utils/tests/unit/storages/test_pg.py,sha256=hOR8WSvnuRJKH_rD2vcSMDOJqs7EndJqaPNrTENBOy8,17016
|
73
|
-
nucliadb_utils/tests/unit/storages/test_storage.py,sha256=OT21FUnQTU2oxxaFfVC1LMkJ34jyW7Leit5ZCQgNyZ0,7131
|
74
|
-
nucliadb_utils-4.0.3.post573.dist-info/METADATA,sha256=J6qLIji36yg5u_FlNBi--qMxI31j6ltFSCzGNs6d0pA,2030
|
75
|
-
nucliadb_utils-4.0.3.post573.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
76
|
-
nucliadb_utils-4.0.3.post573.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
77
|
-
nucliadb_utils-4.0.3.post573.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
78
|
-
nucliadb_utils-4.0.3.post573.dist-info/RECORD,,
|
59
|
+
nucliadb_utils-4.0.3.post576.dist-info/METADATA,sha256=FDR1ykGQMbczBRujCFNZTl4g-YXGq9cXO9fUwANBdUE,2030
|
60
|
+
nucliadb_utils-4.0.3.post576.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
61
|
+
nucliadb_utils-4.0.3.post576.dist-info/top_level.txt,sha256=fE3vJtALTfgh7bcAWcNhcfXkNPp_eVVpbKK-2IYua3E,15
|
62
|
+
nucliadb_utils-4.0.3.post576.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
63
|
+
nucliadb_utils-4.0.3.post576.dist-info/RECORD,,
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# Copyright (C) 2021 Bosutech XXI S.L.
|
2
|
-
#
|
3
|
-
# nucliadb is offered under the AGPL v3.0 and as commercial software.
|
4
|
-
# For commercial licensing, contact us at info@nuclia.com.
|
5
|
-
#
|
6
|
-
# AGPL:
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU Affero General Public License as
|
9
|
-
# published by the Free Software Foundation, either version 3 of the
|
10
|
-
# License, or (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU Affero General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU Affero General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# Copyright (C) 2021 Bosutech XXI S.L.
|
2
|
-
#
|
3
|
-
# nucliadb is offered under the AGPL v3.0 and as commercial software.
|
4
|
-
# For commercial licensing, contact us at info@nuclia.com.
|
5
|
-
#
|
6
|
-
# AGPL:
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU Affero General Public License as
|
9
|
-
# published by the Free Software Foundation, either version 3 of the
|
10
|
-
# License, or (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU Affero General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU Affero General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# Copyright (C) 2021 Bosutech XXI S.L.
|
2
|
-
#
|
3
|
-
# nucliadb is offered under the AGPL v3.0 and as commercial software.
|
4
|
-
# For commercial licensing, contact us at info@nuclia.com.
|
5
|
-
#
|
6
|
-
# AGPL:
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU Affero General Public License as
|
9
|
-
# published by the Free Software Foundation, either version 3 of the
|
10
|
-
# License, or (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU Affero General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU Affero General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
|
20
|
-
import botocore # type: ignore
|
21
|
-
import pytest
|
22
|
-
|
23
|
-
from nucliadb_utils.storages import s3
|
24
|
-
from nucliadb_utils.storages.exceptions import UnparsableResponse
|
25
|
-
|
26
|
-
|
27
|
-
@pytest.mark.parametrize(
|
28
|
-
"code,expected",
|
29
|
-
[
|
30
|
-
("200", 200),
|
31
|
-
("404", 404),
|
32
|
-
("409", 409),
|
33
|
-
("NoSuchBucket", 404),
|
34
|
-
("NoSuchKey", 404),
|
35
|
-
("BucketNotEmpty", 409),
|
36
|
-
],
|
37
|
-
)
|
38
|
-
def test_parse_status_code(response_generator, code: str, expected: int):
|
39
|
-
resp = response_generator(code)
|
40
|
-
assert s3.parse_status_code(resp) == expected
|
41
|
-
|
42
|
-
|
43
|
-
def test_unparsable_status_code(response_generator):
|
44
|
-
resp = response_generator("Unknown")
|
45
|
-
with pytest.raises(UnparsableResponse):
|
46
|
-
s3.parse_status_code(resp)
|
47
|
-
|
48
|
-
|
49
|
-
@pytest.fixture
|
50
|
-
def response_generator():
|
51
|
-
class TestError(botocore.exceptions.ClientError):
|
52
|
-
def __init__(self, error_code: str):
|
53
|
-
response = {
|
54
|
-
"Error": {
|
55
|
-
"Code": error_code,
|
56
|
-
}
|
57
|
-
}
|
58
|
-
super().__init__(error_response=response, operation_name="TEST") # type: ignore
|
59
|
-
|
60
|
-
yield TestError
|
@@ -1,119 +0,0 @@
|
|
1
|
-
# Copyright (C) 2021 Bosutech XXI S.L.
|
2
|
-
#
|
3
|
-
# nucliadb is offered under the AGPL v3.0 and as commercial software.
|
4
|
-
# For commercial licensing, contact us at info@nuclia.com.
|
5
|
-
#
|
6
|
-
# AGPL:
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU Affero General Public License as
|
9
|
-
# published by the Free Software Foundation, either version 3 of the
|
10
|
-
# License, or (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU Affero General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU Affero General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
|
20
|
-
from unittest.mock import AsyncMock, Mock, call, patch
|
21
|
-
|
22
|
-
import aiohttp
|
23
|
-
import pytest
|
24
|
-
|
25
|
-
from nucliadb_utils.storages.gcs import (
|
26
|
-
GCSStorage,
|
27
|
-
GCSStorageField,
|
28
|
-
GoogleCloudException,
|
29
|
-
ReadingResponseContentException,
|
30
|
-
)
|
31
|
-
|
32
|
-
|
33
|
-
@pytest.fixture(scope="function")
|
34
|
-
def storage_field():
|
35
|
-
yield GCSStorageField("bucket", "fullkey", "field")
|
36
|
-
|
37
|
-
|
38
|
-
@pytest.fixture(scope="function")
|
39
|
-
def asyncio_sleep():
|
40
|
-
with patch("nucliadb_utils.storages.gcs.asyncio.sleep") as asyncio_sleep:
|
41
|
-
yield asyncio_sleep
|
42
|
-
|
43
|
-
|
44
|
-
class MockInnerIterData:
|
45
|
-
def __init__(self, error=None, to_yield=None):
|
46
|
-
self.error = error
|
47
|
-
self.to_yield = to_yield
|
48
|
-
self.await_count = 0
|
49
|
-
|
50
|
-
async def __call__(self, **kwargs):
|
51
|
-
self.await_count += 1
|
52
|
-
if self.error:
|
53
|
-
raise self.error
|
54
|
-
for item in self.to_yield:
|
55
|
-
yield item
|
56
|
-
|
57
|
-
|
58
|
-
@pytest.mark.parametrize(
|
59
|
-
"error", [GoogleCloudException, aiohttp.client_exceptions.ServerDisconnectedError]
|
60
|
-
)
|
61
|
-
async def test_iter_data_error_retries(storage_field, error, asyncio_sleep):
|
62
|
-
storage_field._inner_iter_data = MockInnerIterData(error=error)
|
63
|
-
|
64
|
-
with pytest.raises(error):
|
65
|
-
async for _ in storage_field.iter_data():
|
66
|
-
pass
|
67
|
-
|
68
|
-
storage_field._inner_iter_data.await_count == 4
|
69
|
-
assert asyncio_sleep.call_args_list == [call(1), call(2), call(4)]
|
70
|
-
|
71
|
-
|
72
|
-
async def test_iter_data_reading_content_error_is_not_retried(storage_field):
|
73
|
-
storage_field._inner_iter_data = MockInnerIterData(
|
74
|
-
error=ReadingResponseContentException
|
75
|
-
)
|
76
|
-
|
77
|
-
with pytest.raises(ReadingResponseContentException):
|
78
|
-
async for _ in storage_field.iter_data():
|
79
|
-
pass
|
80
|
-
|
81
|
-
storage_field._inner_iter_data.await_count == 1
|
82
|
-
|
83
|
-
|
84
|
-
@pytest.mark.asyncio
|
85
|
-
async def test_delete_kb_errors():
|
86
|
-
kbid = "my-kbid"
|
87
|
-
storage = GCSStorage(bucket="bucket")
|
88
|
-
|
89
|
-
# Let's mock session.delete to return a mock response
|
90
|
-
response_mock = AsyncMock()
|
91
|
-
|
92
|
-
delete_context = Mock()
|
93
|
-
delete_context.__aenter__ = AsyncMock(return_value=response_mock)
|
94
|
-
delete_context.__aexit__ = AsyncMock()
|
95
|
-
|
96
|
-
storage.session = Mock()
|
97
|
-
storage.session.delete = Mock(return_value=delete_context)
|
98
|
-
|
99
|
-
# Test GCS responses and how we behave
|
100
|
-
|
101
|
-
response_mock.status = 204
|
102
|
-
deleted, conflict = await storage.delete_kb(kbid)
|
103
|
-
assert deleted
|
104
|
-
assert not conflict
|
105
|
-
|
106
|
-
response_mock.status = 404
|
107
|
-
deleted, conflict = await storage.delete_kb(kbid)
|
108
|
-
assert not deleted
|
109
|
-
assert not conflict
|
110
|
-
|
111
|
-
response_mock.status = 409
|
112
|
-
deleted, conflict = await storage.delete_kb(kbid)
|
113
|
-
assert not deleted
|
114
|
-
assert conflict
|
115
|
-
|
116
|
-
response_mock.status = 500
|
117
|
-
deleted, conflict = await storage.delete_kb(kbid)
|
118
|
-
assert not deleted
|
119
|
-
assert not conflict
|