edu-rdm-integration 3.11.2__py3-none-any.whl → 3.12.0__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.
Potentially problematic release.
This version of edu-rdm-integration might be problematic. Click here for more details.
- edu_rdm_integration/stages/export_data/functions/base/consts.py +3 -0
- edu_rdm_integration/stages/export_data/functions/base/functions.py +21 -7
- edu_rdm_integration/stages/export_data/functions/base/tests.py +161 -0
- {edu_rdm_integration-3.11.2.dist-info → edu_rdm_integration-3.12.0.dist-info}/METADATA +2 -2
- {edu_rdm_integration-3.11.2.dist-info → edu_rdm_integration-3.12.0.dist-info}/RECORD +8 -8
- {edu_rdm_integration-3.11.2.dist-info → edu_rdm_integration-3.12.0.dist-info}/WHEEL +0 -0
- {edu_rdm_integration-3.11.2.dist-info → edu_rdm_integration-3.12.0.dist-info}/licenses/LICENSE +0 -0
- {edu_rdm_integration-3.11.2.dist-info → edu_rdm_integration-3.12.0.dist-info}/top_level.txt +0 -0
|
@@ -72,11 +72,6 @@ class BaseExportDataFunction(
|
|
|
72
72
|
RDMExportingDataSubStageEntity.objects.create(
|
|
73
73
|
exporting_data_sub_stage=self._sub_stage, entity_id=self.first_entity.key
|
|
74
74
|
)
|
|
75
|
-
# Проставление подэтапа выгрузки
|
|
76
|
-
self.entities[0].main_model_enum.model.objects.filter(pk__in=model_ids).update(
|
|
77
|
-
exporting_sub_stage=self._sub_stage,
|
|
78
|
-
)
|
|
79
|
-
|
|
80
75
|
self._chunk_index = kwargs.get('chunk_index')
|
|
81
76
|
|
|
82
77
|
logger.info(f'{LOGS_DELIMITER * 3}{repr(self._sub_stage)} created.')
|
|
@@ -90,6 +85,13 @@ class BaseExportDataFunction(
|
|
|
90
85
|
}
|
|
91
86
|
|
|
92
87
|
self.has_data = False
|
|
88
|
+
# Id записей моделей РВД, которые в итоге попали в файл
|
|
89
|
+
self.exported_to_file_model_ids = set()
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def _models_unique_id(self) -> str:
|
|
93
|
+
"""Возвращает название уникального идентификатора записи модели рвд."""
|
|
94
|
+
return 'id'
|
|
93
95
|
|
|
94
96
|
def _prepare_helper_class(self) -> type[BaseExportDataFunctionHelper]:
|
|
95
97
|
"""Возвращает класс помощника функции."""
|
|
@@ -141,8 +143,9 @@ class BaseExportDataFunction(
|
|
|
141
143
|
entity_instance=entity_instance,
|
|
142
144
|
)
|
|
143
145
|
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
entity_instance_id = getattr(entity_instance, self._models_unique_id, None)
|
|
147
|
+
if entity_instance_id:
|
|
148
|
+
self.exported_to_file_model_ids.add(entity_instance_id)
|
|
146
149
|
|
|
147
150
|
for operation in EntityLogOperation.values.keys():
|
|
148
151
|
entities = self._data.get(operation)
|
|
@@ -217,9 +220,20 @@ class BaseExportDataFunction(
|
|
|
217
220
|
if not self.has_data
|
|
218
221
|
else RDMExportingDataSubStageStatus.READY_FOR_EXPORT.key
|
|
219
222
|
)
|
|
223
|
+
# Проставление подэтапа выгрузки
|
|
224
|
+
if self.exported_to_file_model_ids:
|
|
225
|
+
self.entities[0].main_model_enum.model.objects.filter(pk__in=self.exported_to_file_model_ids).update(
|
|
226
|
+
exporting_sub_stage=self._sub_stage,
|
|
227
|
+
)
|
|
228
|
+
|
|
220
229
|
else:
|
|
221
230
|
self._sub_stage.status_id = RDMExportingDataSubStageStatus.FAILED.key
|
|
222
231
|
|
|
223
232
|
self._sub_stage.save()
|
|
224
233
|
|
|
225
234
|
logger.info(f'{LOGS_DELIMITER * 3}change status {repr(self._sub_stage)}')
|
|
235
|
+
|
|
236
|
+
def get_function_data(self):
|
|
237
|
+
"""Возвращает словарь с данными сущностей подготовленных к выгрузке."""
|
|
238
|
+
return self._data
|
|
239
|
+
|
|
@@ -1 +1,162 @@
|
|
|
1
1
|
# Реализуйте свои unit-тесты здесь
|
|
2
|
+
import datetime
|
|
3
|
+
import shutil
|
|
4
|
+
from typing import (
|
|
5
|
+
TYPE_CHECKING,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
from django.conf import (
|
|
9
|
+
settings,
|
|
10
|
+
)
|
|
11
|
+
from django.test import (
|
|
12
|
+
TestCase,
|
|
13
|
+
override_settings,
|
|
14
|
+
)
|
|
15
|
+
from django.utils import (
|
|
16
|
+
timezone,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
from function_tools.models import (
|
|
20
|
+
Entity,
|
|
21
|
+
EntityType,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
from edu_rdm_integration.core.consts import (
|
|
25
|
+
REGIONAL_DATA_MART_INTEGRATION_COLLECTING_DATA,
|
|
26
|
+
REGIONAL_DATA_MART_INTEGRATION_EXPORTING_DATA,
|
|
27
|
+
)
|
|
28
|
+
from edu_rdm_integration.stages.collect_data.models import (
|
|
29
|
+
CollectingExportedDataStage,
|
|
30
|
+
CollectingExportedDataSubStage,
|
|
31
|
+
)
|
|
32
|
+
from edu_rdm_integration.stages.export_data.functions.base.consts import (
|
|
33
|
+
TEST_DIR,
|
|
34
|
+
)
|
|
35
|
+
from edu_rdm_integration.stages.export_data.models import (
|
|
36
|
+
ExportingDataStage,
|
|
37
|
+
ExportingDataSubStage,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if TYPE_CHECKING:
|
|
42
|
+
from function_tools.managers import (
|
|
43
|
+
RunnerManager,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
from edu_rdm_integration.stages.export_data.functions.base.functions import (
|
|
47
|
+
BaseExportDataFunction,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class BaseExportTestCase(TestCase):
|
|
52
|
+
"""Базовый тест экспорта сущности РВД."""
|
|
53
|
+
|
|
54
|
+
databases = (settings.DEFAULT_DB_ALIAS, settings.SERVICE_DB_ALIAS)
|
|
55
|
+
|
|
56
|
+
def setUp(self) -> None:
|
|
57
|
+
"""Подготавливает фикстуры."""
|
|
58
|
+
self.now = timezone.now()
|
|
59
|
+
|
|
60
|
+
self.export_period_started_at = datetime.datetime.combine(self.now, datetime.time.min)
|
|
61
|
+
self.export_period_ended_at = datetime.datetime.combine(self.now, datetime.time.max)
|
|
62
|
+
|
|
63
|
+
def create_sub_stage(self, *class_names: str) -> CollectingExportedDataSubStage:
|
|
64
|
+
"""Создает подэтап сбора данных."""
|
|
65
|
+
function_tools_entities = dict(
|
|
66
|
+
Entity.objects.filter(
|
|
67
|
+
type__in=(EntityType.MANAGER.key, EntityType.FUNCTION.key),
|
|
68
|
+
tags__contains=[REGIONAL_DATA_MART_INTEGRATION_COLLECTING_DATA],
|
|
69
|
+
class_name__in=class_names,
|
|
70
|
+
).values_list('type', 'uuid'),
|
|
71
|
+
)
|
|
72
|
+
stage = CollectingExportedDataStage.objects.create(
|
|
73
|
+
manager_id=function_tools_entities[EntityType.MANAGER.key],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
return CollectingExportedDataSubStage.objects.create(
|
|
77
|
+
function_id=function_tools_entities[EntityType.FUNCTION.key],
|
|
78
|
+
stage=stage,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def tearDownClass(cls) -> None:
|
|
83
|
+
try:
|
|
84
|
+
shutil.rmtree(TEST_DIR)
|
|
85
|
+
except OSError:
|
|
86
|
+
pass
|
|
87
|
+
|
|
88
|
+
super().tearDownClass()
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class BaseExportManagerTestCase(BaseExportTestCase):
|
|
92
|
+
"""Базовый тест менеджера экспорта сущности РВД."""
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def manager(self) -> type['RunnerManager']:
|
|
96
|
+
"""Менеджер раннера Функции экспорта'."""
|
|
97
|
+
raise NotImplementedError
|
|
98
|
+
|
|
99
|
+
@override_settings(MEDIA_ROOT=(TEST_DIR + '/media'))
|
|
100
|
+
def run_exporting_manager(self) -> None:
|
|
101
|
+
"""Запускает менеджер экспорта."""
|
|
102
|
+
runner_manager = self.manager(
|
|
103
|
+
period_started_at=self.export_period_started_at,
|
|
104
|
+
period_ended_at=self.export_period_ended_at,
|
|
105
|
+
)
|
|
106
|
+
runner_manager.run()
|
|
107
|
+
|
|
108
|
+
def get_exporting_stage_sub_stage(self, *class_names) -> tuple[ExportingDataStage, ExportingDataSubStage]:
|
|
109
|
+
"""Возвращает этап и подэтап экспорта."""
|
|
110
|
+
function_tools_entities = dict(
|
|
111
|
+
Entity.objects.filter(
|
|
112
|
+
type__in=(EntityType.MANAGER.key, EntityType.FUNCTION.key),
|
|
113
|
+
tags__contains=[REGIONAL_DATA_MART_INTEGRATION_EXPORTING_DATA],
|
|
114
|
+
class_name__in=class_names,
|
|
115
|
+
).values_list('type', 'uuid'),
|
|
116
|
+
)
|
|
117
|
+
exported_data_stage = ExportingDataStage.objects.filter(
|
|
118
|
+
manager_id=function_tools_entities[EntityType.MANAGER.key],
|
|
119
|
+
period_started_at=self.export_period_started_at,
|
|
120
|
+
period_ended_at=self.export_period_ended_at,
|
|
121
|
+
).first()
|
|
122
|
+
exported_data_substage = ExportingDataSubStage.objects.filter(
|
|
123
|
+
function_id=function_tools_entities[EntityType.FUNCTION.key],
|
|
124
|
+
stage=exported_data_stage
|
|
125
|
+
).first()
|
|
126
|
+
|
|
127
|
+
return exported_data_stage, exported_data_substage
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class BaseExportFunctionTestCase(BaseExportTestCase):
|
|
131
|
+
"""Базовый тест менеджера экспорта сущности РВД."""
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def export_function(self) -> type['BaseExportDataFunction']:
|
|
135
|
+
"""Функция экспорта."""
|
|
136
|
+
raise NotImplementedError
|
|
137
|
+
|
|
138
|
+
def create_exporting_stage(self, *class_names: str) -> ExportingDataStage:
|
|
139
|
+
"""Создает этап экспорта данных."""
|
|
140
|
+
function_tools_entities = dict(
|
|
141
|
+
Entity.objects.filter(
|
|
142
|
+
type__in=(EntityType.MANAGER.key, EntityType.FUNCTION.key),
|
|
143
|
+
tags__contains=[REGIONAL_DATA_MART_INTEGRATION_EXPORTING_DATA],
|
|
144
|
+
class_name__in=class_names,
|
|
145
|
+
).values_list('type', 'uuid'),
|
|
146
|
+
)
|
|
147
|
+
return ExportingDataStage.objects.create(
|
|
148
|
+
manager_id=function_tools_entities[EntityType.MANAGER.key],
|
|
149
|
+
period_started_at=self.export_period_started_at,
|
|
150
|
+
period_ended_at=self.export_period_ended_at,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
@override_settings(MEDIA_ROOT=(TEST_DIR + '/media'))
|
|
154
|
+
def run_exporting_function(self, exporting_stage: ExportingDataStage, model_ids: list[int]) -> dict:
|
|
155
|
+
"""Запускает функцию экспорта."""
|
|
156
|
+
exporting_function = self.export_function(
|
|
157
|
+
stage=exporting_stage,
|
|
158
|
+
model_ids=model_ids
|
|
159
|
+
)
|
|
160
|
+
exporting_function.run()
|
|
161
|
+
|
|
162
|
+
return exporting_function.get_function_data()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edu-rdm-integration
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.12.0
|
|
4
4
|
Summary: Интеграция с Региональной витриной данных
|
|
5
5
|
Author-email: BARS Group <education_dev@bars.group>
|
|
6
6
|
Project-URL: Homepage, https://stash.bars-open.ru/projects/EDUBASE/repos/edu-rdm-integration/browse
|
|
@@ -25,7 +25,7 @@ Requires-Dist: transliterate<2
|
|
|
25
25
|
Requires-Dist: Django<5.0,>=3.1
|
|
26
26
|
Requires-Dist: celery<5.3,>=4.4.7
|
|
27
27
|
Requires-Dist: asyncpg==0.23.0
|
|
28
|
-
Requires-Dist: educommon<4,>=3.
|
|
28
|
+
Requires-Dist: educommon<4,>=3.21.0
|
|
29
29
|
Requires-Dist: function-tools<1,>=0.9.0
|
|
30
30
|
Requires-Dist: m3-db-utils<1,>=0.3.10
|
|
31
31
|
Requires-Dist: m3-django-compat<2,>=1.10.2
|
|
@@ -199,10 +199,10 @@ edu_rdm_integration/stages/export_data/function_templates/function_export_data_t
|
|
|
199
199
|
edu_rdm_integration/stages/export_data/functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
200
200
|
edu_rdm_integration/stages/export_data/functions/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
201
201
|
edu_rdm_integration/stages/export_data/functions/base/caches.py,sha256=WsZY0hUzhydCuC0KO-04norF9qTmncdX_Txk5HTgiFc,1478
|
|
202
|
-
edu_rdm_integration/stages/export_data/functions/base/consts.py,sha256=
|
|
202
|
+
edu_rdm_integration/stages/export_data/functions/base/consts.py,sha256=wRwgxRhQ21uFm9vF0Ub_R7cmep2nYWqGFQDxsIiM2ys,544
|
|
203
203
|
edu_rdm_integration/stages/export_data/functions/base/enums.py,sha256=BSmwrkzYwEQhz9NbZCJsldY532PqgZJzxzsVk6ue0bM,93
|
|
204
204
|
edu_rdm_integration/stages/export_data/functions/base/errors.py,sha256=LusnB7wDkF8upSAgnxPb2c9N51QiTfp3G1l2-3J2AnM,281
|
|
205
|
-
edu_rdm_integration/stages/export_data/functions/base/functions.py,sha256=
|
|
205
|
+
edu_rdm_integration/stages/export_data/functions/base/functions.py,sha256=4ydnkqQXUjydzV5okrwATIH-UdGjDctX1fgzmWMdSaM,9484
|
|
206
206
|
edu_rdm_integration/stages/export_data/functions/base/helpers.py,sha256=f2CFUd6Efu7ZIljjjMi71UxWRFJr3q2mn4nyZPQVCLU,4517
|
|
207
207
|
edu_rdm_integration/stages/export_data/functions/base/managers.py,sha256=RvUjBYl8e6akA0hD7Qlaa_foGB5r0AfsyAFzyGL8o38,6098
|
|
208
208
|
edu_rdm_integration/stages/export_data/functions/base/presenters.py,sha256=83BvbpXlR8Pn7EyyWOuJJneQyWs5F8U0ugZK0FoRDUE,393
|
|
@@ -210,7 +210,7 @@ edu_rdm_integration/stages/export_data/functions/base/requests.py,sha256=kZkjuNB
|
|
|
210
210
|
edu_rdm_integration/stages/export_data/functions/base/results.py,sha256=asAaDbbm9REFit7HweqdEZPvYUPH8GP-wh4FHJo5B4U,527
|
|
211
211
|
edu_rdm_integration/stages/export_data/functions/base/runners.py,sha256=QK5WjWK-nnOJ1MdEGCVosFpuRFWpPWOzYQfJN5cIBl0,2438
|
|
212
212
|
edu_rdm_integration/stages/export_data/functions/base/strings.py,sha256=-k9dex8A7hCpkzUkudVkKRAbNRuuqog2hYl2xmibl8I,181
|
|
213
|
-
edu_rdm_integration/stages/export_data/functions/base/tests.py,sha256=
|
|
213
|
+
edu_rdm_integration/stages/export_data/functions/base/tests.py,sha256=Kxlf3aXzGcZ6QqfozCxlSrRU0l1lIcFDgupstOnwwhM,5756
|
|
214
214
|
edu_rdm_integration/stages/export_data/functions/base/validators.py,sha256=s6Ne37zMS5UOyB-Od2fFQDmvD2c0jBWZ_XFUaaYX-6I,905
|
|
215
215
|
edu_rdm_integration/stages/export_data/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
216
216
|
edu_rdm_integration/stages/export_data/management/base.py,sha256=u_4Oc6F5OoMiYH7BHYD42Vv7c56vnHxFVqNyPaPv6MI,4068
|
|
@@ -259,8 +259,8 @@ edu_rdm_integration/stages/upload_data/uploader_log/ui.py,sha256=mU3XA9zVKHGqzNk
|
|
|
259
259
|
edu_rdm_integration/stages/upload_data/uploader_log/migrations/0001_initial.py,sha256=r5oOB7DBK9-mfuqPAgjXUJY5-hEcmMdILCwDTpaLnBc,753
|
|
260
260
|
edu_rdm_integration/stages/upload_data/uploader_log/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
261
261
|
edu_rdm_integration/stages/upload_data/uploader_log/templates/ui-js/object-grid-buttons.js,sha256=2xyGe0wdVokM0RhpzRzcRvJPBkBmPe3SlZry4oP4Nzs,6201
|
|
262
|
-
edu_rdm_integration-3.
|
|
263
|
-
edu_rdm_integration-3.
|
|
264
|
-
edu_rdm_integration-3.
|
|
265
|
-
edu_rdm_integration-3.
|
|
266
|
-
edu_rdm_integration-3.
|
|
262
|
+
edu_rdm_integration-3.12.0.dist-info/licenses/LICENSE,sha256=uw43Gjjj-1vXWCItfSrNDpbejnOwZMrNerUh8oWbq8Q,3458
|
|
263
|
+
edu_rdm_integration-3.12.0.dist-info/METADATA,sha256=RN9RcZsmrWMilZyredeZmb_9M_PICTrNxrhPvXfmIEs,39698
|
|
264
|
+
edu_rdm_integration-3.12.0.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
|
265
|
+
edu_rdm_integration-3.12.0.dist-info/top_level.txt,sha256=nRJV0O14UtNE-jGIYG03sohgFnZClvf57H5m6VBXe9Y,20
|
|
266
|
+
edu_rdm_integration-3.12.0.dist-info/RECORD,,
|
|
File without changes
|
{edu_rdm_integration-3.11.2.dist-info → edu_rdm_integration-3.12.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|