-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
LTD-5703-add-ars
- Loading branch information
Showing
4 changed files
with
169 additions
and
1 deletion.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
api/staticdata/report_summaries/migrations/0010_add_ars_prefix_dec_2024.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import json | ||
|
||
from django.db import migrations | ||
|
||
DATA_PATH = "api/staticdata/report_summaries/migrations/data/0010_add_ars_prefix_dec_2024/" | ||
|
||
|
||
def populate_report_summaries(apps, schema_editor): | ||
|
||
ReportSummaryPrefix = apps.get_model("report_summaries", "ReportSummaryPrefix") | ||
with open(f"{DATA_PATH}/report_summary_prefix.json") as json_file: | ||
records = json.load(json_file) | ||
for attributes in records: | ||
ReportSummaryPrefix.objects.create(**attributes) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [("report_summaries", "0009_add_ars_subject_prefix_oct_2024")] | ||
operations = [migrations.RunPython(populate_report_summaries, migrations.RunPython.noop)] |
110 changes: 110 additions & 0 deletions
110
.../report_summaries/migrations/data/0010_add_ars_prefix_dec_2024/report_summary_prefix.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
[ | ||
{ | ||
"id": "7b9e40d5-daa0-4936-a396-999f102802db", | ||
"name": "components for training" | ||
}, | ||
{ | ||
"id": "d9c63989-f282-4bca-9f41-7c47a9b5bb45", | ||
"name": "technology for equipment for the production of" | ||
}, | ||
{ | ||
"id": "b90c0700-239f-400a-8993-8b848fa0eb40", | ||
"name": "technology for accessories for" | ||
}, | ||
{ | ||
"id": "0f9a0f6f-f2aa-474c-b0ce-bcd131280763", | ||
"name": "technology for components for" | ||
}, | ||
{ | ||
"id": "00ed0089-b001-42b8-8269-a80c9fe6f5e6", | ||
"name": "technology for production facilities for" | ||
}, | ||
{ | ||
"id": "d170137d-0e8e-49af-8e2e-4823cb30d141", | ||
"name": "technology for equipment for the use of" | ||
}, | ||
{ | ||
"id": "12fb818d-5f45-46eb-9b27-c19e7879902d", | ||
"name": "technology for equipment for the development of" | ||
}, | ||
{ | ||
"id": "750c60cf-0851-420f-85d8-ed5c93f11f2a", | ||
"name": "technology for software for" | ||
}, | ||
{ | ||
"id": "c9cb488c-e389-49df-8cd6-35b67970185b", | ||
"name": "software for accessories for" | ||
}, | ||
{ | ||
"id": "ea187231-3e41-4a00-82f3-0146011fd65d", | ||
"name": "software for components for" | ||
}, | ||
{ | ||
"id": "b3693806-e775-46a2-b9af-13c62f8faf27", | ||
"name": "software for production facilities for" | ||
}, | ||
{ | ||
"id": "b2d86c51-5ee1-47f6-9a74-8713f25b7303", | ||
"name": "software for equipment for the use of" | ||
}, | ||
{ | ||
"id": "4373571f-d0a0-49bc-9ae5-4c398ad21a18", | ||
"name": "software for equipment for the production of" | ||
}, | ||
{ | ||
"id": "cdce636f-065b-4dfa-b6c1-a666793b2195", | ||
"name": "software for equipment for the development of" | ||
}, | ||
{ | ||
"id": "970126b6-e735-47cb-8401-fc31199bcbdf", | ||
"name": "software for technology for" | ||
}, | ||
{ | ||
"id": "c616aa24-21da-44ed-8ebe-6da5e214ccdd", | ||
"name": "technology for software for accessories for" | ||
}, | ||
{ | ||
"id": "ea40d261-c059-4e40-a592-2bc05673937c", | ||
"name": "technology for software for components for" | ||
}, | ||
{ | ||
"id": "b8889393-4b5d-4be7-9cd8-bef21251758c", | ||
"name": "technology for software for production facilities for" | ||
}, | ||
{ | ||
"id": "cf1d8f29-f84b-48f7-9b1a-e575ad499f65", | ||
"name": "technology for software for equipment for the use of" | ||
}, | ||
{ | ||
"id": "20ecc6b0-1200-4e79-91a9-c8ae878b46ae", | ||
"name": "technology for software for equipment for the production of" | ||
}, | ||
{ | ||
"id": "d1ffdbcb-313b-4dae-9052-1d92f8124d52", | ||
"name": "technology for software for equipment for the development of" | ||
}, | ||
{ | ||
"id": "ebc0f475-458c-4124-b835-8a6448431901", | ||
"name": "software for technology for accessories for" | ||
}, | ||
{ | ||
"id": "b53aac5b-5247-4576-ae6b-9b57c27974f4", | ||
"name": "software for technology for components for" | ||
}, | ||
{ | ||
"id": "b3d2ca48-f51f-4737-b03c-425618fb4872", | ||
"name": "software for technology for production facilities for" | ||
}, | ||
{ | ||
"id": "6571c253-80f1-465e-91d2-78bdbacc8381", | ||
"name": "software for technology for equipment for the use of" | ||
}, | ||
{ | ||
"id": "7f7f1b7d-7c1e-4418-ba31-cf1267719d74", | ||
"name": "software for technology for equipment for the production of" | ||
}, | ||
{ | ||
"id": "3bfa5e70-7d64-4972-9696-8b60d0506b29", | ||
"name": "software for technology for equipment for the development of" | ||
} | ||
] |
27 changes: 27 additions & 0 deletions
27
api/staticdata/report_summaries/migrations/tests/test_0010_add_ars_prefix_dec_2024.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import json | ||
import pytest | ||
|
||
FIXTURE_BASE = "api/staticdata/report_summaries/migrations/data/0010_add_ars_prefix_dec_2024/" | ||
INITIAL_MIGRATION = "0009_add_ars_subject_prefix_oct_2024" | ||
MIGRATION_UNDER_TEST = "0010_add_ars_prefix_dec_2024" | ||
|
||
|
||
@pytest.mark.django_db() | ||
def test_add_ars_prefix_dec(migrator): | ||
with open(FIXTURE_BASE + "report_summary_prefix.json") as prefix_json_file: | ||
report_summary_prefix_data = json.load(prefix_json_file) | ||
|
||
old_state = migrator.apply_initial_migration(("report_summaries", INITIAL_MIGRATION)) | ||
ReportSummaryPrefix = old_state.apps.get_model("report_summaries", "ReportSummaryPrefix") | ||
|
||
for prefix_to_add in report_summary_prefix_data: | ||
assert not ReportSummaryPrefix.objects.filter(name=prefix_to_add["name"]).exists() | ||
assert not ReportSummaryPrefix.objects.filter(id=prefix_to_add["id"]).exists() | ||
|
||
new_state = migrator.apply_tested_migration(("report_summaries", MIGRATION_UNDER_TEST)) | ||
|
||
ReportSummaryPrefix = new_state.apps.get_model("report_summaries", "ReportSummaryPrefix") | ||
|
||
for expected_prefix in report_summary_prefix_data: | ||
prefix = ReportSummaryPrefix.objects.get(name=expected_prefix["name"]) | ||
assert str(prefix.id) == expected_prefix["id"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters