hapi-schema 0.6.0__tar.gz → 0.6.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.6.0 → hapi_schema-0.6.2}/.config/pre-commit-config.yaml +8 -9
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/.config/ruff.toml +8 -6
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/PKG-INFO +3 -3
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/changelog.md +6 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/contributing.md +26 -9
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/pyproject.toml +5 -8
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/requirements.txt +12 -10
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/_version.py +2 -2
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_admin1.py +1 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_admin2.py +1 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_food_security.py +2 -1
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_humanitarian_needs.py +1 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_location.py +1 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_national_risk.py +26 -6
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_operational_presence.py +2 -1
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_org.py +1 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_population.py +1 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_sector.py +1 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_national_risk.py +1 -1
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_national_risk_view.py +2 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_org_type_view.py +1 -1
- hapi_schema-0.6.0/.config/black.toml +0 -2
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/.config/coveragerc +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/.config/pytest.ini +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/.github/workflows/publish.yaml +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/.github/workflows/run-python-tests.yaml +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/.gitignore +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/LICENSE +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/README.md +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/__init__.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_age_range.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_dataset.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_gender.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_ipc_phase.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_ipc_type.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_org_type.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_population_group.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_population_status.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/db_resource.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/utils/__init__.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/utils/base.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/src/hapi_schema/utils/view_params.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/conftest.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/__init__.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_admin1.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_admin2.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_age_range.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_dataset.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_food_security.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_gender.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_humanitarian_needs.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_ipc_phase.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_ipc_type.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_location.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_operational_presence.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_org.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_org_type.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_population.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_population_group.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_population_status.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_resource.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/sample_data/data_sector.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_admin1_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_admin2_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_age_range_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_dataset_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_food_security_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_gender_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_humanitarian_needs_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_ipc_phase_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_ipc_type_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_location_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_operational_presence_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_org_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_population_group_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_population_status_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_population_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_resource_view.py +0 -0
- {hapi_schema-0.6.0 → hapi_schema-0.6.2}/tests/test_sector_view.py +0 -0
|
@@ -2,21 +2,20 @@ default_language_version:
|
|
|
2
2
|
python: python3.11
|
|
3
3
|
repos:
|
|
4
4
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
-
rev: v4.
|
|
5
|
+
rev: v4.5.0
|
|
6
6
|
hooks:
|
|
7
7
|
- id: trailing-whitespace
|
|
8
8
|
- id: end-of-file-fixer
|
|
9
9
|
- id: check-ast
|
|
10
|
-
- repo: https://github.com/
|
|
11
|
-
rev:
|
|
12
|
-
hooks:
|
|
13
|
-
- id: black
|
|
14
|
-
args: [--config, .config/black.toml]
|
|
15
|
-
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
|
16
|
-
rev: v0.0.292
|
|
10
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
11
|
+
rev: v0.1.14
|
|
17
12
|
hooks:
|
|
13
|
+
# Run the linter.
|
|
18
14
|
- id: ruff
|
|
19
|
-
args: [--config, .config/ruff.toml, --fix
|
|
15
|
+
args: [--config, .config/ruff.toml, --fix]
|
|
16
|
+
# Run the formatter.
|
|
17
|
+
- id: ruff-format
|
|
18
|
+
args: [--config, .config/ruff.toml]
|
|
20
19
|
- repo: https://github.com/jazzband/pip-tools
|
|
21
20
|
rev: 7.3.0
|
|
22
21
|
hooks:
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
line-length = 79
|
|
2
2
|
exclude = ["_version.py"]
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# List of rules: https://beta.ruff.rs/docs/rules/
|
|
3
|
+
|
|
4
|
+
[lint]
|
|
5
|
+
# List of rules: https://docs.astral.sh/ruff/rules/
|
|
7
6
|
select = [
|
|
8
7
|
"E", # pycodestyle - default
|
|
9
8
|
"F", # pyflakes - default
|
|
10
9
|
"I" # isort
|
|
11
10
|
]
|
|
11
|
+
ignore = [
|
|
12
|
+
"E501" # Line too long
|
|
13
|
+
]
|
|
12
14
|
|
|
13
|
-
[isort]
|
|
14
|
-
known-local-folder=['hapi_schema', 'sample_data']
|
|
15
|
+
[lint.isort]
|
|
16
|
+
known-local-folder = ['hapi_schema', 'sample_data']
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hapi-schema
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: HAPI database schema specified in SQLAlchemy
|
|
5
5
|
Project-URL: Homepage, https://github.com/OCHA-DAP/hapi-schemas
|
|
6
6
|
Author-email: Simon Johnson <simon.johnson@un.org>
|
|
@@ -26,11 +26,11 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
26
26
|
Requires-Python: >=3.8
|
|
27
27
|
Requires-Dist: sqlalchemy
|
|
28
28
|
Provides-Extra: database
|
|
29
|
-
Requires-Dist: hdx-python-database>=1.
|
|
29
|
+
Requires-Dist: hdx-python-database>=1.3.0; extra == 'database'
|
|
30
30
|
Provides-Extra: dev
|
|
31
31
|
Requires-Dist: pre-commit; extra == 'dev'
|
|
32
32
|
Provides-Extra: test
|
|
33
|
-
Requires-Dist: hdx-python-database>=1.
|
|
33
|
+
Requires-Dist: hdx-python-database>=1.3.0; extra == 'test'
|
|
34
34
|
Requires-Dist: pytest; extra == 'test'
|
|
35
35
|
Requires-Dist: pytest-cov; extra == 'test'
|
|
36
36
|
Description-Content-Type: text/markdown
|
|
@@ -5,6 +5,12 @@ 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.6.1]
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- National risk location link
|
|
13
|
+
|
|
8
14
|
## [0.6.0]
|
|
9
15
|
|
|
10
16
|
### Added
|
|
@@ -13,13 +13,6 @@ development by running:
|
|
|
13
13
|
|
|
14
14
|
pip install -r requirements.txt
|
|
15
15
|
|
|
16
|
-
## Testing
|
|
17
|
-
|
|
18
|
-
To run the tests and view coverage, execute:
|
|
19
|
-
|
|
20
|
-
pytest -c .config/pytest.ini --cov hapi_schema --cov-config .config/coveragerc
|
|
21
|
-
|
|
22
|
-
|
|
23
16
|
## Pre-Commit
|
|
24
17
|
|
|
25
18
|
Also be sure to install `pre-commit`, which is run every time
|
|
@@ -28,16 +21,40 @@ you make a git commit:
|
|
|
28
21
|
pre-commit install
|
|
29
22
|
|
|
30
23
|
The configuration file for this project is in a
|
|
31
|
-
non-
|
|
24
|
+
non-standard location. Thus, you will need to edit your
|
|
32
25
|
`.git/hooks/pre-commit` file to reflect this. Change
|
|
33
26
|
the line that begins with `ARGS` to:
|
|
34
27
|
|
|
35
28
|
ARGS=(hook-impl --config=.config/pre-commit-config.yaml --hook-type=pre-commit)
|
|
36
29
|
|
|
37
30
|
With pre-commit, all code is formatted according to
|
|
38
|
-
[black]("https://github.com/psf/black") and
|
|
39
31
|
[ruff]("https://github.com/charliermarsh/ruff") guidelines.
|
|
40
32
|
|
|
41
33
|
To check if your changes pass pre-commit without committing, run:
|
|
42
34
|
|
|
43
35
|
pre-commit run --all-files --config=.config/pre-commit-config.yaml
|
|
36
|
+
|
|
37
|
+
## Testing
|
|
38
|
+
|
|
39
|
+
To run the tests and view coverage, execute:
|
|
40
|
+
|
|
41
|
+
pytest -c .config/pytest.ini --cov hapi_schema --cov-config .config/coveragerc
|
|
42
|
+
|
|
43
|
+
Follow the example set out already in ``documentation/main.md`` as you write the documentation.
|
|
44
|
+
|
|
45
|
+
## Packages
|
|
46
|
+
|
|
47
|
+
[pip-tools](https://github.com/jazzband/pip-tools) is used for
|
|
48
|
+
package management. If you’ve introduced a new package to the
|
|
49
|
+
source code (i.e.anywhere in `src/`), please add it to the
|
|
50
|
+
`project.dependencies` section of
|
|
51
|
+
`pyproject.toml` with any known version constraints.
|
|
52
|
+
|
|
53
|
+
For adding packages for testing or development, add them to
|
|
54
|
+
the `test` or `dev` sections under `[project.optional-dependencies]`.
|
|
55
|
+
|
|
56
|
+
Any changes to the dependencies will be automatically reflected in
|
|
57
|
+
`requirements.txt` with `pre-commit`, but you can re-generate
|
|
58
|
+
the file without committing by executing:
|
|
59
|
+
|
|
60
|
+
pre-commit run pip-compile --all-files --config=.config/pre-commit-config.yaml
|
|
@@ -42,9 +42,9 @@ content-type = "text/markdown"
|
|
|
42
42
|
Homepage = "https://github.com/OCHA-DAP/hapi-schemas"
|
|
43
43
|
|
|
44
44
|
[project.optional-dependencies]
|
|
45
|
-
database = ["hdx-python-database>=1.
|
|
45
|
+
database = ["hdx-python-database>=1.3.0"]
|
|
46
46
|
dev = ["pre-commit"]
|
|
47
|
-
test = ["hdx-python-database>=1.
|
|
47
|
+
test = ["hdx-python-database>=1.3.0", "pytest", "pytest-cov"]
|
|
48
48
|
|
|
49
49
|
#########
|
|
50
50
|
# Hatch #
|
|
@@ -87,13 +87,10 @@ python = ["3.11"]
|
|
|
87
87
|
|
|
88
88
|
[tool.hatch.envs.lint]
|
|
89
89
|
detached = true
|
|
90
|
-
dependencies = [
|
|
91
|
-
"black",
|
|
92
|
-
"ruff",
|
|
93
|
-
]
|
|
90
|
+
dependencies = ["ruff"]
|
|
94
91
|
|
|
95
92
|
[tool.hatch.envs.lint.scripts]
|
|
96
93
|
style = [
|
|
97
|
-
"ruff --config .config/ruff.toml {args:.}",
|
|
98
|
-
"
|
|
94
|
+
"ruff check --config .config/ruff.toml --diff {args:.}",
|
|
95
|
+
"ruff format --config .config/ruff.toml --diff {args:.}",
|
|
99
96
|
]
|
|
@@ -6,17 +6,19 @@
|
|
|
6
6
|
#
|
|
7
7
|
cfgv==3.4.0
|
|
8
8
|
# via pre-commit
|
|
9
|
-
coverage[toml]==7.4.
|
|
10
|
-
# via
|
|
9
|
+
coverage[toml]==7.4.3
|
|
10
|
+
# via
|
|
11
|
+
# coverage
|
|
12
|
+
# pytest-cov
|
|
11
13
|
distlib==0.3.8
|
|
12
14
|
# via virtualenv
|
|
13
15
|
filelock==3.13.1
|
|
14
16
|
# via virtualenv
|
|
15
17
|
greenlet==3.0.3
|
|
16
18
|
# via sqlalchemy
|
|
17
|
-
hdx-python-database==1.
|
|
19
|
+
hdx-python-database==1.3.0
|
|
18
20
|
# via hapi-schema (pyproject.toml)
|
|
19
|
-
identify==2.5.
|
|
21
|
+
identify==2.5.35
|
|
20
22
|
# via pre-commit
|
|
21
23
|
iniconfig==2.0.0
|
|
22
24
|
# via pytest
|
|
@@ -24,13 +26,13 @@ nodeenv==1.8.0
|
|
|
24
26
|
# via pre-commit
|
|
25
27
|
packaging==23.2
|
|
26
28
|
# via pytest
|
|
27
|
-
platformdirs==4.
|
|
29
|
+
platformdirs==4.2.0
|
|
28
30
|
# via virtualenv
|
|
29
|
-
pluggy==1.
|
|
31
|
+
pluggy==1.4.0
|
|
30
32
|
# via pytest
|
|
31
|
-
pre-commit==3.6.
|
|
33
|
+
pre-commit==3.6.2
|
|
32
34
|
# via hapi-schema (pyproject.toml)
|
|
33
|
-
pytest==
|
|
35
|
+
pytest==8.0.2
|
|
34
36
|
# via
|
|
35
37
|
# hapi-schema (pyproject.toml)
|
|
36
38
|
# pytest-cov
|
|
@@ -38,13 +40,13 @@ pytest-cov==4.1.0
|
|
|
38
40
|
# via hapi-schema (pyproject.toml)
|
|
39
41
|
pyyaml==6.0.1
|
|
40
42
|
# via pre-commit
|
|
41
|
-
sqlalchemy==2.0.
|
|
43
|
+
sqlalchemy==2.0.27
|
|
42
44
|
# via
|
|
43
45
|
# hapi-schema (pyproject.toml)
|
|
44
46
|
# hdx-python-database
|
|
45
47
|
typing-extensions==4.9.0
|
|
46
48
|
# via sqlalchemy
|
|
47
|
-
virtualenv==20.25.
|
|
49
|
+
virtualenv==20.25.1
|
|
48
50
|
# via pre-commit
|
|
49
51
|
|
|
50
52
|
# The following packages are considered to be unsafe in a requirements file:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Population table and view."""
|
|
2
|
+
|
|
2
3
|
from datetime import datetime
|
|
3
4
|
|
|
4
5
|
from sqlalchemy import (
|
|
@@ -79,7 +80,7 @@ view_params_food_security = ViewParams(
|
|
|
79
80
|
DBAdmin1.is_unspecified.label("admin1_is_unspecified"),
|
|
80
81
|
DBAdmin2.code.label("admin2_code"),
|
|
81
82
|
DBAdmin2.name.label("admin2_name"),
|
|
82
|
-
DBAdmin2.is_unspecified.label("admin2_is_unspecified")
|
|
83
|
+
DBAdmin2.is_unspecified.label("admin2_is_unspecified"),
|
|
83
84
|
).select_from(
|
|
84
85
|
# Join pop to admin2 to admin1 to loc
|
|
85
86
|
DBFoodSecurity.__table__.join(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""NationalRisk table and view."""
|
|
2
|
+
|
|
2
3
|
from datetime import datetime
|
|
3
4
|
|
|
4
5
|
from sqlalchemy import (
|
|
@@ -12,6 +13,8 @@ from sqlalchemy import (
|
|
|
12
13
|
)
|
|
13
14
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
14
15
|
|
|
16
|
+
from hapi_schema.db_admin1 import DBAdmin1
|
|
17
|
+
from hapi_schema.db_admin2 import DBAdmin2
|
|
15
18
|
from hapi_schema.db_dataset import DBDataset
|
|
16
19
|
from hapi_schema.db_location import DBLocation
|
|
17
20
|
from hapi_schema.db_resource import DBResource
|
|
@@ -27,8 +30,8 @@ class DBNationalRisk(Base):
|
|
|
27
30
|
ForeignKey("resource.id", onupdate="CASCADE", ondelete="CASCADE"),
|
|
28
31
|
nullable=False,
|
|
29
32
|
)
|
|
30
|
-
|
|
31
|
-
ForeignKey("
|
|
33
|
+
admin2_ref: Mapped[int] = mapped_column(
|
|
34
|
+
ForeignKey("admin2.id", onupdate="CASCADE"), nullable=False
|
|
32
35
|
)
|
|
33
36
|
risk_class: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
34
37
|
global_rank: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
@@ -51,7 +54,7 @@ class DBNationalRisk(Base):
|
|
|
51
54
|
source_data: Mapped[str] = mapped_column(Text, nullable=True)
|
|
52
55
|
|
|
53
56
|
resource = relationship("DBResource")
|
|
54
|
-
|
|
57
|
+
admin2 = relationship("DBAdmin2")
|
|
55
58
|
|
|
56
59
|
|
|
57
60
|
view_params_national_risk = ViewParams(
|
|
@@ -69,11 +72,27 @@ view_params_national_risk = ViewParams(
|
|
|
69
72
|
DBResource.update_date.label("resource_update_date"),
|
|
70
73
|
DBLocation.code.label("location_code"),
|
|
71
74
|
DBLocation.name.label("location_name"),
|
|
75
|
+
DBAdmin1.code.label("admin1_code"),
|
|
76
|
+
DBAdmin1.name.label("admin1_name"),
|
|
77
|
+
DBAdmin1.is_unspecified.label("admin1_is_unspecified"),
|
|
78
|
+
DBAdmin2.code.label("admin2_code"),
|
|
79
|
+
DBAdmin2.name.label("admin2_name"),
|
|
80
|
+
DBAdmin2.is_unspecified.label("admin2_is_unspecified"),
|
|
72
81
|
).select_from(
|
|
73
|
-
# Join risk to loc
|
|
82
|
+
# Join risk to admin 2 to admin 1 to loc
|
|
74
83
|
DBNationalRisk.__table__.join(
|
|
84
|
+
DBAdmin2.__table__,
|
|
85
|
+
DBNationalRisk.admin2_ref == DBAdmin2.id,
|
|
86
|
+
isouter=True,
|
|
87
|
+
)
|
|
88
|
+
.join(
|
|
89
|
+
DBAdmin1.__table__,
|
|
90
|
+
DBAdmin2.admin1_ref == DBAdmin1.id,
|
|
91
|
+
isouter=True,
|
|
92
|
+
)
|
|
93
|
+
.join(
|
|
75
94
|
DBLocation.__table__,
|
|
76
|
-
|
|
95
|
+
DBAdmin1.location_ref == DBLocation.id,
|
|
77
96
|
isouter=True,
|
|
78
97
|
)
|
|
79
98
|
# Join risk to resource to dataset
|
|
@@ -81,7 +100,8 @@ view_params_national_risk = ViewParams(
|
|
|
81
100
|
DBResource.__table__,
|
|
82
101
|
DBNationalRisk.resource_ref == DBResource.id,
|
|
83
102
|
isouter=True,
|
|
84
|
-
)
|
|
103
|
+
)
|
|
104
|
+
.join(
|
|
85
105
|
DBDataset.__table__,
|
|
86
106
|
DBResource.dataset_ref == DBDataset.id,
|
|
87
107
|
isouter=True,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""OperationalPresence table and view."""
|
|
2
|
+
|
|
2
3
|
from datetime import datetime
|
|
3
4
|
|
|
4
5
|
from sqlalchemy import (
|
|
@@ -79,7 +80,7 @@ view_params_operational_presence = ViewParams(
|
|
|
79
80
|
DBOrg.name.label("org_name"),
|
|
80
81
|
DBOrg.org_type_code.label("org_type_code"),
|
|
81
82
|
DBOrgType.description.label("org_type_description"),
|
|
82
|
-
DBSector.name.label("sector_name")
|
|
83
|
+
DBSector.name.label("sector_name"),
|
|
83
84
|
).select_from(
|
|
84
85
|
# Join op to admin2 to admin1 to loc
|
|
85
86
|
DBOperationalPresence.__table__.join(
|
|
@@ -14,6 +14,8 @@ def test_national_risk_view(run_view_test):
|
|
|
14
14
|
== "c3f001fa-b45b-464c-9460-1ca79fd39b40",
|
|
15
15
|
view_national_risk.c.resource_hdx_id
|
|
16
16
|
== "90deb235-1bf5-4bae-b231-3393222c2d01",
|
|
17
|
+
view_national_risk.c.admin2_code == "FOO-XXX-XXX",
|
|
18
|
+
view_national_risk.c.admin1_code == "FOO-XXX",
|
|
17
19
|
view_national_risk.c.location_code == "FOO",
|
|
18
20
|
),
|
|
19
21
|
)
|
|
@@ -5,7 +5,7 @@ from hapi_schema.db_org_type import view_params_org_type
|
|
|
5
5
|
|
|
6
6
|
def test_org_type_view(run_view_test):
|
|
7
7
|
"""Check that org type has all fields."""
|
|
8
|
-
dict(code="433", description="Donor"),
|
|
8
|
+
(dict(code="433", description="Donor"),)
|
|
9
9
|
view_org_type = build_view(view_params_org_type.__dict__)
|
|
10
10
|
run_view_test(
|
|
11
11
|
view=view_org_type,
|
|
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
|
|
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
|