hapi-schema 0.9.0__tar.gz → 0.9.2__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.
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/.config/pre-commit-config.yaml +2 -2
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/PKG-INFO +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/changelog.md +14 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/requirements.txt +12 -12
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/_version.py +2 -2
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_humanitarian_needs.py +1 -22
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_views_as_tables.py +1 -13
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/enums.py +0 -6
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/view_as_table_definitions.toml +3 -3
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/views.py +9 -4
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_humanitarian_needs.py +4 -19
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_conflict_event.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_food_price.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_food_security.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_funding.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_humanitarian_needs.py +5 -57
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_idps.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_national_risk.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_operational_presence.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_population.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_poverty_rate.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_refugees.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_returnees.py +1 -1
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_views_as_tables.py +1 -6
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/.config/coveragerc +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/.config/pytest.ini +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/.config/ruff.toml +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/.github/workflows/publish.yaml +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/.github/workflows/run-python-tests.yaml +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/.gitignore +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/LICENSE +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/README.md +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/contributing.md +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/docker/docker-compose.yml +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/initialize_test_db.sh +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/pyproject.toml +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/__init__.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_admin1.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_admin2.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_conflict_event.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_currency.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_dataset.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_food_price.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_food_security.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_funding.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_idps.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_location.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_national_risk.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_operational_presence.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_org.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_org_type.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_patch.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_population.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_poverty_rate.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_refugees.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_resource.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_returnees.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_sector.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_wfp_commodity.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/db_wfp_market.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/__init__.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/base.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/constraints.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/hapi_views_code_generator.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/view_as_table_code_generator.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/view_params.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/conftest.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/__init__.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_admin1.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_admin2.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_conflict_event.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_currency.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_dataset.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_food_price.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_food_security.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_funding.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_idps.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_location.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_national_risk.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_operational_presence.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_org.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_org_type.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_patch.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_population.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_poverty_rate.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_refugees.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_resource.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_returnees.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_sector.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_wfp_commodity.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/sample_data/data_wfp_market.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_admin1.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_admin2.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_currency.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_dataset.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_location.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_org.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_org_type.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_patch.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_resource.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_sector.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_wfp_commodity.py +0 -0
- {hapi_schema-0.9.0 → hapi_schema-0.9.2}/tests/test_wfp_market.py +0 -0
|
@@ -8,7 +8,7 @@ repos:
|
|
|
8
8
|
- id: end-of-file-fixer
|
|
9
9
|
- id: check-ast
|
|
10
10
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
11
|
-
rev: v0.
|
|
11
|
+
rev: v0.6.9
|
|
12
12
|
hooks:
|
|
13
13
|
# Run the linter.
|
|
14
14
|
- id: ruff
|
|
@@ -17,7 +17,7 @@ repos:
|
|
|
17
17
|
- id: ruff-format
|
|
18
18
|
args: [--config, .config/ruff.toml]
|
|
19
19
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
20
|
-
rev: 0.
|
|
20
|
+
rev: 0.4.18
|
|
21
21
|
hooks:
|
|
22
22
|
# Run the pip compile
|
|
23
23
|
- id: pip-compile
|
|
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 0.9.2
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Freeform category for HNO instead of gender, age, disabled, population group
|
|
13
|
+
|
|
14
|
+
## 0.9.1
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Return views from prepare_hapi_views call
|
|
19
|
+
|
|
8
20
|
## 0.9.0
|
|
9
21
|
|
|
10
22
|
### Added
|
|
@@ -26,6 +38,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
26
38
|
### Changed
|
|
27
39
|
|
|
28
40
|
- added "Producer" to the `PriceType` enum
|
|
41
|
+
- humanitarian needs table changes - replace gender, age, disability and
|
|
42
|
+
population group columns with freeform category column
|
|
29
43
|
|
|
30
44
|
## 0.8.17
|
|
31
45
|
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
# uv pip compile pyproject.toml --resolver=backtracking --all-extras -o requirements.txt
|
|
3
3
|
cfgv==3.4.0
|
|
4
4
|
# via pre-commit
|
|
5
|
-
coverage==7.6.
|
|
5
|
+
coverage==7.6.3
|
|
6
6
|
# via pytest-cov
|
|
7
|
-
distlib==0.3.
|
|
7
|
+
distlib==0.3.9
|
|
8
8
|
# via virtualenv
|
|
9
|
-
filelock==3.
|
|
9
|
+
filelock==3.16.1
|
|
10
10
|
# via virtualenv
|
|
11
|
-
greenlet==3.
|
|
11
|
+
greenlet==3.1.1
|
|
12
12
|
# via sqlalchemy
|
|
13
13
|
hdx-python-database==1.3.3
|
|
14
14
|
# via hapi-schema (pyproject.toml)
|
|
15
|
-
identify==2.6.
|
|
15
|
+
identify==2.6.1
|
|
16
16
|
# via pre-commit
|
|
17
17
|
iniconfig==2.0.0
|
|
18
18
|
# via pytest
|
|
@@ -20,17 +20,17 @@ nodeenv==1.9.1
|
|
|
20
20
|
# via pre-commit
|
|
21
21
|
packaging==24.1
|
|
22
22
|
# via pytest
|
|
23
|
-
platformdirs==4.
|
|
23
|
+
platformdirs==4.3.6
|
|
24
24
|
# via virtualenv
|
|
25
25
|
pluggy==1.5.0
|
|
26
26
|
# via pytest
|
|
27
|
-
pre-commit==
|
|
27
|
+
pre-commit==4.0.1
|
|
28
28
|
# via hapi-schema (pyproject.toml)
|
|
29
|
-
psycopg==3.2.
|
|
29
|
+
psycopg==3.2.3
|
|
30
30
|
# via hapi-schema (pyproject.toml)
|
|
31
|
-
psycopg-binary==3.2.
|
|
31
|
+
psycopg-binary==3.2.3
|
|
32
32
|
# via psycopg
|
|
33
|
-
pytest==8.3.
|
|
33
|
+
pytest==8.3.3
|
|
34
34
|
# via
|
|
35
35
|
# hapi-schema (pyproject.toml)
|
|
36
36
|
# pytest-cov
|
|
@@ -38,7 +38,7 @@ pytest-cov==5.0.0
|
|
|
38
38
|
# via hapi-schema (pyproject.toml)
|
|
39
39
|
pyyaml==6.0.2
|
|
40
40
|
# via pre-commit
|
|
41
|
-
sqlalchemy==2.0.
|
|
41
|
+
sqlalchemy==2.0.35
|
|
42
42
|
# via
|
|
43
43
|
# hapi-schema (pyproject.toml)
|
|
44
44
|
# hdx-python-database
|
|
@@ -46,5 +46,5 @@ typing-extensions==4.12.2
|
|
|
46
46
|
# via
|
|
47
47
|
# psycopg
|
|
48
48
|
# sqlalchemy
|
|
49
|
-
virtualenv==20.26.
|
|
49
|
+
virtualenv==20.26.6
|
|
50
50
|
# via pre-commit
|
|
@@ -18,15 +18,10 @@ from hapi_schema.db_resource import DBResource
|
|
|
18
18
|
from hapi_schema.db_sector import DBSector
|
|
19
19
|
from hapi_schema.utils.base import Base
|
|
20
20
|
from hapi_schema.utils.constraints import (
|
|
21
|
-
max_age_constraint,
|
|
22
|
-
min_age_constraint,
|
|
23
21
|
population_constraint,
|
|
24
22
|
reference_period_constraint,
|
|
25
23
|
)
|
|
26
24
|
from hapi_schema.utils.enums import (
|
|
27
|
-
DisabledMarker,
|
|
28
|
-
Gender,
|
|
29
|
-
PopulationGroup,
|
|
30
25
|
PopulationStatus,
|
|
31
26
|
build_enum_using_values,
|
|
32
27
|
)
|
|
@@ -36,8 +31,6 @@ from hapi_schema.utils.view_params import ViewParams
|
|
|
36
31
|
class DBHumanitarianNeeds(Base):
|
|
37
32
|
__tablename__ = "humanitarian_needs"
|
|
38
33
|
__table_args__ = (
|
|
39
|
-
min_age_constraint(),
|
|
40
|
-
max_age_constraint(),
|
|
41
34
|
population_constraint(),
|
|
42
35
|
reference_period_constraint(),
|
|
43
36
|
)
|
|
@@ -52,29 +45,15 @@ class DBHumanitarianNeeds(Base):
|
|
|
52
45
|
)
|
|
53
46
|
provider_admin1_name = mapped_column(String(512), primary_key=True)
|
|
54
47
|
provider_admin2_name = mapped_column(String(512), primary_key=True)
|
|
55
|
-
|
|
56
|
-
build_enum_using_values(Gender), primary_key=True
|
|
57
|
-
)
|
|
58
|
-
age_range: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
59
|
-
min_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
|
|
60
|
-
max_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
|
|
48
|
+
category: Mapped[str] = mapped_column(String(128), primary_key=True)
|
|
61
49
|
sector_code: Mapped[str] = mapped_column(
|
|
62
50
|
ForeignKey("sector.code", onupdate="CASCADE"),
|
|
63
51
|
primary_key=True,
|
|
64
52
|
)
|
|
65
|
-
population_group: Mapped[PopulationGroup] = mapped_column(
|
|
66
|
-
build_enum_using_values(PopulationGroup),
|
|
67
|
-
primary_key=True,
|
|
68
|
-
)
|
|
69
|
-
|
|
70
53
|
population_status: Mapped[PopulationStatus] = mapped_column(
|
|
71
54
|
build_enum_using_values(PopulationStatus),
|
|
72
55
|
primary_key=True,
|
|
73
56
|
)
|
|
74
|
-
|
|
75
|
-
disabled_marker: Mapped[DisabledMarker] = mapped_column(
|
|
76
|
-
build_enum_using_values(DisabledMarker), primary_key=True
|
|
77
|
-
)
|
|
78
57
|
population: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
79
58
|
reference_period_start: Mapped[datetime] = mapped_column(
|
|
80
59
|
primary_key=True,
|
|
@@ -13,7 +13,6 @@ from sqlalchemy.orm import Mapped, mapped_column
|
|
|
13
13
|
from hapi_schema.utils.base import Base
|
|
14
14
|
from hapi_schema.utils.enums import (
|
|
15
15
|
CommodityCategory,
|
|
16
|
-
DisabledMarker,
|
|
17
16
|
EventType,
|
|
18
17
|
Gender,
|
|
19
18
|
IPCPhase,
|
|
@@ -250,22 +249,11 @@ class DBHumanitarianNeedsVAT(Base):
|
|
|
250
249
|
provider_admin2_name: Mapped[str] = mapped_column(
|
|
251
250
|
String(512), primary_key=True
|
|
252
251
|
)
|
|
253
|
-
|
|
254
|
-
build_enum_using_values(Gender), primary_key=True
|
|
255
|
-
)
|
|
256
|
-
age_range: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
257
|
-
min_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
|
|
258
|
-
max_age: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
|
|
252
|
+
category: Mapped[str] = mapped_column(String(128), primary_key=True)
|
|
259
253
|
sector_code: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
260
|
-
population_group: Mapped[PopulationGroup] = mapped_column(
|
|
261
|
-
build_enum_using_values(PopulationGroup), primary_key=True
|
|
262
|
-
)
|
|
263
254
|
population_status: Mapped[PopulationStatus] = mapped_column(
|
|
264
255
|
build_enum_using_values(PopulationStatus), primary_key=True
|
|
265
256
|
)
|
|
266
|
-
disabled_marker: Mapped[DisabledMarker] = mapped_column(
|
|
267
|
-
build_enum_using_values(DisabledMarker), primary_key=True
|
|
268
|
-
)
|
|
269
257
|
population: Mapped[int] = mapped_column(Integer)
|
|
270
258
|
reference_period_start: Mapped[datetime] = mapped_column(
|
|
271
259
|
DateTime, primary_key=True
|
|
@@ -28,12 +28,6 @@ class DTMAssessmentType(str, PythonEnum):
|
|
|
28
28
|
SITE = "SA"
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
class DisabledMarker(str, PythonEnum):
|
|
32
|
-
YES = "y"
|
|
33
|
-
NO = "n"
|
|
34
|
-
ALL = "all"
|
|
35
|
-
|
|
36
|
-
|
|
37
31
|
class EventType(str, PythonEnum):
|
|
38
32
|
CIVILIAN_TARGETING = "civilian_targeting"
|
|
39
33
|
DEMONSTRATION = "demonstration"
|
{hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/view_as_table_definitions.toml
RENAMED
|
@@ -80,10 +80,10 @@ expected_nullables = ["reference_period_end"]
|
|
|
80
80
|
db_module = "db_humanitarian_needs"
|
|
81
81
|
target_view = "humanitarian_needs_view"
|
|
82
82
|
view_params_name="view_params_humanitarian_needs"
|
|
83
|
-
expected_primary_keys = ["admin2_ref", "
|
|
84
|
-
expected_indexes = ["
|
|
83
|
+
expected_primary_keys = ["admin2_ref", "category", "population_status", "population", "reference_period_start"]
|
|
84
|
+
expected_indexes = ["reference_period_end",
|
|
85
85
|
"location_code", "location_name", "admin1_code", "admin1_name", "admin2_code", "admin2_name"]
|
|
86
|
-
expected_nullables = [
|
|
86
|
+
expected_nullables = []
|
|
87
87
|
|
|
88
88
|
[[tables]]
|
|
89
89
|
db_module = "db_location"
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
import os
|
|
3
3
|
from importlib import import_module
|
|
4
|
+
from typing import Dict
|
|
4
5
|
|
|
6
|
+
from sqlalchemy import TableClause
|
|
5
7
|
from sqlalchemy.sql.expression import union_all
|
|
6
8
|
|
|
7
9
|
from hapi_schema.utils.base import Base
|
|
@@ -14,7 +16,7 @@ except ImportError:
|
|
|
14
16
|
pass
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
def prepare_hapi_views():
|
|
19
|
+
def prepare_hapi_views() -> Dict[str, TableClause]:
|
|
18
20
|
# Programmatically get views and prepare them for creation.
|
|
19
21
|
# Views must be in files with filename of form: db_{name}.py in the same
|
|
20
22
|
# directory. Views must be named like this: view_params_{name}.
|
|
@@ -22,6 +24,7 @@ def prepare_hapi_views():
|
|
|
22
24
|
path = inspect.getabsfile(prepare_hapi_views)
|
|
23
25
|
dirpath, _ = os.path.split(path)
|
|
24
26
|
availability_stmts = []
|
|
27
|
+
views = {}
|
|
25
28
|
for path in os.listdir(dirpath):
|
|
26
29
|
if os.path.isdir(path):
|
|
27
30
|
continue
|
|
@@ -32,7 +35,7 @@ def prepare_hapi_views():
|
|
|
32
35
|
table = filename[3:]
|
|
33
36
|
try:
|
|
34
37
|
view_params = getattr(module, f"view_params_{table}")
|
|
35
|
-
Database.prepare_view(view_params.__dict__)
|
|
38
|
+
views[table] = Database.prepare_view(view_params.__dict__)
|
|
36
39
|
availability_stmt = getattr(
|
|
37
40
|
module, f"availability_stmt_{table}"
|
|
38
41
|
)
|
|
@@ -48,5 +51,7 @@ def prepare_hapi_views():
|
|
|
48
51
|
selectable=union_all(*availability_stmts),
|
|
49
52
|
)
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
views["data_availability"] = Database.prepare_view(
|
|
55
|
+
view_params_availability.__dict__
|
|
56
|
+
)
|
|
57
|
+
return views
|
|
@@ -7,11 +7,8 @@ data_humanitarian_needs = [
|
|
|
7
7
|
admin2_ref=1,
|
|
8
8
|
provider_admin1_name="Provincia 01",
|
|
9
9
|
provider_admin2_name="Distrito B",
|
|
10
|
-
|
|
11
|
-
age_range="all",
|
|
12
|
-
disabled_marker="all",
|
|
10
|
+
category="",
|
|
13
11
|
sector_code="intersectoral",
|
|
14
|
-
population_group="all",
|
|
15
12
|
population_status="AFF",
|
|
16
13
|
population=1_000_000,
|
|
17
14
|
reference_period_start=datetime(2023, 1, 1),
|
|
@@ -23,11 +20,8 @@ data_humanitarian_needs = [
|
|
|
23
20
|
admin2_ref=1,
|
|
24
21
|
provider_admin1_name="Provincia 01",
|
|
25
22
|
provider_admin2_name="Distrito B",
|
|
26
|
-
|
|
27
|
-
age_range="all",
|
|
28
|
-
disabled_marker="n",
|
|
23
|
+
category="Female - Refugees",
|
|
29
24
|
sector_code="SHL",
|
|
30
|
-
population_group="REF",
|
|
31
25
|
population_status="INN",
|
|
32
26
|
population=500_000,
|
|
33
27
|
reference_period_start=datetime(2023, 1, 1),
|
|
@@ -39,13 +33,8 @@ data_humanitarian_needs = [
|
|
|
39
33
|
admin2_ref=2,
|
|
40
34
|
provider_admin1_name="Provincia 01",
|
|
41
35
|
provider_admin2_name="Distrito B",
|
|
42
|
-
|
|
43
|
-
age_range="0-4",
|
|
44
|
-
min_age=0,
|
|
45
|
-
max_age=4,
|
|
46
|
-
disabled_marker="y",
|
|
36
|
+
category="Female - Disabled - Baby - IDP",
|
|
47
37
|
sector_code="WSH",
|
|
48
|
-
population_group="IDP",
|
|
49
38
|
population_status="INN",
|
|
50
39
|
population=5_000,
|
|
51
40
|
reference_period_start=datetime(2023, 1, 1),
|
|
@@ -57,12 +46,8 @@ data_humanitarian_needs = [
|
|
|
57
46
|
admin2_ref=4,
|
|
58
47
|
provider_admin1_name="Provincia 03",
|
|
59
48
|
provider_admin2_name="Distrito D",
|
|
60
|
-
|
|
61
|
-
age_range="80+",
|
|
62
|
-
min_age=80,
|
|
63
|
-
disabled_marker="y",
|
|
49
|
+
category="Elderly - Disabled - IDP",
|
|
64
50
|
sector_code="HEA",
|
|
65
|
-
population_group="IDP",
|
|
66
51
|
population_status="AFF",
|
|
67
52
|
population=500,
|
|
68
53
|
reference_period_start=datetime(2023, 1, 1),
|
|
@@ -29,7 +29,7 @@ def test_conflict_event_view(run_view_test):
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def test_conflict_event_availability(run_view_test):
|
|
32
|
-
view_availability = prepare_hapi_views()
|
|
32
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
33
33
|
run_view_test(
|
|
34
34
|
view=view_availability,
|
|
35
35
|
whereclause=(
|
|
@@ -39,7 +39,7 @@ def test_food_price_view(run_view_test):
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def test_food_price_availability(run_view_test):
|
|
42
|
-
view_availability = prepare_hapi_views()
|
|
42
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
43
43
|
run_view_test(
|
|
44
44
|
view=view_availability,
|
|
45
45
|
whereclause=(
|
|
@@ -29,7 +29,7 @@ def test_food_security_view(run_view_test):
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def test_food_security_availability(run_view_test):
|
|
32
|
-
view_availability = prepare_hapi_views()
|
|
32
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
33
33
|
run_view_test(
|
|
34
34
|
view=view_availability,
|
|
35
35
|
whereclause=(
|
|
@@ -31,7 +31,7 @@ def test_funding_view(run_view_test):
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
def test_funding_availability(run_view_test):
|
|
34
|
-
view_availability = prepare_hapi_views()
|
|
34
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
35
35
|
run_view_test(
|
|
36
36
|
view=view_availability,
|
|
37
37
|
whereclause=(
|
|
@@ -7,12 +7,7 @@ from hapi_schema.db_humanitarian_needs import (
|
|
|
7
7
|
DBHumanitarianNeeds,
|
|
8
8
|
view_params_humanitarian_needs,
|
|
9
9
|
)
|
|
10
|
-
from hapi_schema.utils.enums import
|
|
11
|
-
DisabledMarker,
|
|
12
|
-
Gender,
|
|
13
|
-
PopulationGroup,
|
|
14
|
-
PopulationStatus,
|
|
15
|
-
)
|
|
10
|
+
from hapi_schema.utils.enums import PopulationStatus
|
|
16
11
|
from hapi_schema.views import prepare_hapi_views
|
|
17
12
|
|
|
18
13
|
|
|
@@ -34,17 +29,16 @@ def test_humanitarian_needs_view(run_view_test):
|
|
|
34
29
|
view_humanitarian_needs.c.admin1_code == "FOO-001",
|
|
35
30
|
view_humanitarian_needs.c.location_code == "FOO",
|
|
36
31
|
view_humanitarian_needs.c.population_status == "INN",
|
|
37
|
-
view_humanitarian_needs.c.
|
|
32
|
+
view_humanitarian_needs.c.category
|
|
33
|
+
== "Female - Disabled - Baby - IDP",
|
|
38
34
|
view_humanitarian_needs.c.sector_name
|
|
39
35
|
== "Water Sanitation Hygiene",
|
|
40
|
-
view_humanitarian_needs.c.gender == "f",
|
|
41
|
-
view_humanitarian_needs.c.disabled_marker == "y", # noqa: E712
|
|
42
36
|
),
|
|
43
37
|
)
|
|
44
38
|
|
|
45
39
|
|
|
46
40
|
def test_humanitarian_needs_availability(run_view_test):
|
|
47
|
-
view_availability = prepare_hapi_views()
|
|
41
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
48
42
|
run_view_test(
|
|
49
43
|
view=view_availability,
|
|
50
44
|
whereclause=(
|
|
@@ -65,11 +59,8 @@ def base_parameters():
|
|
|
65
59
|
admin2_ref=1,
|
|
66
60
|
provider_admin1_name="Provincia 01",
|
|
67
61
|
provider_admin2_name="Distrito B",
|
|
68
|
-
|
|
69
|
-
age_range="-1-20",
|
|
70
|
-
disabled_marker=DisabledMarker.ALL,
|
|
62
|
+
category="",
|
|
71
63
|
sector_code="*",
|
|
72
|
-
population_group=PopulationGroup.ALL,
|
|
73
64
|
population_status=PopulationStatus.AFFECTED,
|
|
74
65
|
population=1_000_000,
|
|
75
66
|
reference_period_start=datetime(2023, 1, 1),
|
|
@@ -101,46 +92,3 @@ def test_population_positive(run_constraints_test, base_parameters):
|
|
|
101
92
|
],
|
|
102
93
|
expected_constraint="population_constraint",
|
|
103
94
|
)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def test_minage(run_constraints_test, base_parameters):
|
|
107
|
-
"""Check that the min_age value is positive, and NULL if
|
|
108
|
-
age_range is all"""
|
|
109
|
-
modified_params = {**base_parameters, **dict(age_range="5-10", min_age=-1)}
|
|
110
|
-
run_constraints_test(
|
|
111
|
-
new_rows=[
|
|
112
|
-
DBHumanitarianNeeds(**modified_params),
|
|
113
|
-
],
|
|
114
|
-
expected_constraint="min_age_constraint",
|
|
115
|
-
)
|
|
116
|
-
modified_params = {**base_parameters, **dict(age_range="all", min_age=10)}
|
|
117
|
-
run_constraints_test(
|
|
118
|
-
new_rows=[
|
|
119
|
-
DBHumanitarianNeeds(**modified_params),
|
|
120
|
-
],
|
|
121
|
-
expected_constraint="min_age_constraint",
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def test_maxage(run_constraints_test, base_parameters):
|
|
126
|
-
"""Check that the max_age is > min_age, and NULL when min_age is NULL"""
|
|
127
|
-
modified_params = {
|
|
128
|
-
**base_parameters,
|
|
129
|
-
**dict(age_range="5-10", min_age=5, max_age=4),
|
|
130
|
-
}
|
|
131
|
-
run_constraints_test(
|
|
132
|
-
new_rows=[
|
|
133
|
-
DBHumanitarianNeeds(**modified_params),
|
|
134
|
-
],
|
|
135
|
-
expected_constraint="max_age_constraint",
|
|
136
|
-
)
|
|
137
|
-
modified_params = {
|
|
138
|
-
**base_parameters,
|
|
139
|
-
**dict(age_range="unknown", min_age=None, max_age=10),
|
|
140
|
-
}
|
|
141
|
-
run_constraints_test(
|
|
142
|
-
new_rows=[
|
|
143
|
-
DBHumanitarianNeeds(**modified_params),
|
|
144
|
-
],
|
|
145
|
-
expected_constraint="max_age_constraint",
|
|
146
|
-
)
|
|
@@ -26,7 +26,7 @@ def test_national_risk_view(run_view_test):
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
def test_national_risk_availability(run_view_test):
|
|
29
|
-
view_availability = prepare_hapi_views()
|
|
29
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
30
30
|
run_view_test(
|
|
31
31
|
view=view_availability,
|
|
32
32
|
whereclause=(
|
|
@@ -35,7 +35,7 @@ def test_operational_presence_view(run_view_test):
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def test_operational_presence_availability(run_view_test):
|
|
38
|
-
view_availability = prepare_hapi_views()
|
|
38
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
39
39
|
run_view_test(
|
|
40
40
|
view=view_availability,
|
|
41
41
|
whereclause=(
|
|
@@ -27,7 +27,7 @@ def test_population_view(run_view_test):
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
def test_population_availability(run_view_test):
|
|
30
|
-
view_availability = prepare_hapi_views()
|
|
30
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
31
31
|
run_view_test(
|
|
32
32
|
view=view_availability,
|
|
33
33
|
whereclause=(
|
|
@@ -27,7 +27,7 @@ def test_poverty_rate_view(run_view_test):
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
def test_poverty_rate_availability(run_view_test):
|
|
30
|
-
view_availability = prepare_hapi_views()
|
|
30
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
31
31
|
run_view_test(
|
|
32
32
|
view=view_availability,
|
|
33
33
|
whereclause=(
|
|
@@ -24,7 +24,7 @@ def test_refugees_view(run_view_test):
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def test_refugees_availability(run_view_test):
|
|
27
|
-
view_availability = prepare_hapi_views()
|
|
27
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
28
28
|
run_view_test(
|
|
29
29
|
view=view_availability,
|
|
30
30
|
whereclause=(
|
|
@@ -24,7 +24,7 @@ def test_returnees_view(run_view_test):
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def test_returnees_availability(run_view_test):
|
|
27
|
-
view_availability = prepare_hapi_views()
|
|
27
|
+
view_availability = prepare_hapi_views()["data_availability"]
|
|
28
28
|
run_view_test(
|
|
29
29
|
view=view_availability,
|
|
30
30
|
whereclause=(
|
|
@@ -200,17 +200,12 @@ def test_humanitarian_needs_vat(
|
|
|
200
200
|
"admin2_ref",
|
|
201
201
|
"provider_admin1_name",
|
|
202
202
|
"provider_admin2_name",
|
|
203
|
-
"gender",
|
|
204
|
-
"age_range",
|
|
205
203
|
"sector_code",
|
|
206
|
-
"
|
|
204
|
+
"category",
|
|
207
205
|
"population_status",
|
|
208
|
-
"disabled_marker",
|
|
209
206
|
"reference_period_start",
|
|
210
207
|
]
|
|
211
208
|
expected_indexes = [
|
|
212
|
-
"min_age",
|
|
213
|
-
"max_age",
|
|
214
209
|
"reference_period_end",
|
|
215
210
|
"location_code",
|
|
216
211
|
"location_name",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hapi_schema-0.9.0 → hapi_schema-0.9.2}/src/hapi_schema/utils/view_as_table_code_generator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|