-
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.
Merge pull request #69 from rl-institut-private/add-metadata-schema-a…
…nd-tests Add population forecast schema, example, and tests
- Loading branch information
Showing
14 changed files
with
466 additions
and
18 deletions.
There are no files selected for viewing
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
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
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,25 @@ | ||
import json | ||
import os | ||
|
||
from config.settings.base import APPS_DIR | ||
|
||
SCHEMAS_DIR = APPS_DIR.path("schemas") | ||
COMPONENTS_DIR = SCHEMAS_DIR.path("components") | ||
|
||
with open(os.path.join(SCHEMAS_DIR, "popup.schema.json"), "rb") as f: | ||
POPUP_SCHEMA = json.loads(f.read()) | ||
|
||
with open(os.path.join(SCHEMAS_DIR, "popup.example.json"), "rb") as f: | ||
POPUP_EXAMPLE = json.loads(f.read()) | ||
|
||
with open(os.path.join(COMPONENTS_DIR, "chart.schema.json"), "rb") as f: | ||
CHART_SCHEMA = json.loads(f.read()) | ||
|
||
with open(os.path.join(COMPONENTS_DIR, "chart.example.json"), "rb") as f: | ||
CHART_EXAMPLE = json.loads(f.read()) | ||
|
||
with open(os.path.join(COMPONENTS_DIR, "sources.schema.json"), "rb") as f: | ||
SOURCES_SCHEMA = json.loads(f.read()) | ||
|
||
with open(os.path.join(COMPONENTS_DIR, "sources.example.json"), "rb") as f: | ||
SOURCES_EXAMPLE = json.loads(f.read()) |
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 |
---|---|---|
@@ -1,20 +1,12 @@ | ||
import pytest | ||
from django.conf import settings | ||
from django.test import RequestFactory | ||
|
||
from digiplan.users.tests.factories import UserFactory | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def media_storage(settings, tmpdir): | ||
settings.MEDIA_ROOT = tmpdir.strpath | ||
|
||
|
||
@pytest.fixture | ||
def user() -> settings.AUTH_USER_MODEL: | ||
return UserFactory() | ||
|
||
|
||
@pytest.fixture | ||
def request_factory() -> RequestFactory: | ||
return RequestFactory() |
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,32 @@ | ||
{ | ||
"chartType": "bar", | ||
"data": { | ||
"definition": { | ||
"key": { | ||
"lookup": "year", | ||
"name": "Year", | ||
"type": "integer" | ||
}, | ||
"value": { | ||
"lookup": "population", | ||
"name": "Population", | ||
"type": "integer" | ||
} | ||
}, | ||
"series": [ | ||
{ | ||
"key": 2022, | ||
"value": 9311 | ||
}, | ||
{ | ||
"key": 2030, | ||
"value": 9182 | ||
}, | ||
{ | ||
"key": 2045, | ||
"value": 8903 | ||
} | ||
] | ||
}, | ||
"title": "Population Forecast" | ||
} |
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,172 @@ | ||
{ | ||
"$id": "https://wam.rl-institut.de/digiplan/schemas/components/chart.schema.json", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"additionalProperties": false, | ||
"description": "Chart Schema. This schema is always referenced by other schemas and can't be standalone", | ||
"properties": { | ||
"chartType": { | ||
"description": "The chart type that shall be used. If no chart shall be used, set value to (JSON type) null. Also look at following source for more info on chart types: https://echarts.apache.org/en/option.html#series", | ||
"enum": [ | ||
"line", | ||
"bar", | ||
"pie", | ||
"scatter", | ||
"effectScatter", | ||
"radar", | ||
"tree", | ||
"treemap", | ||
"sunburst", | ||
"boxplot", | ||
"candlestick", | ||
"heatmap", | ||
"map", | ||
"parallel", | ||
"lines", | ||
"graph", | ||
"sankey", | ||
"funnel", | ||
"gauge", | ||
"pictorialBar", | ||
"themeRiver", | ||
"custom" | ||
], | ||
"type": [ | ||
"string", | ||
"null" | ||
] | ||
}, | ||
"data": { | ||
"additionalProperties": false, | ||
"description": "Data object of chart with key value definitions and items list", | ||
"properties": { | ||
"definition": { | ||
"additionalProperties": false, | ||
"description": "Key-value definition for lookup and human-readable names", | ||
"properties": { | ||
"key": { | ||
"additionalProperties": false, | ||
"description": "Key lookup and name definition", | ||
"properties": { | ||
"lookup": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"type": { | ||
"description": "Possible types, defined by JSON Schema type names", | ||
"enum": [ | ||
"string", | ||
"number", | ||
"integer", | ||
"object", | ||
"array", | ||
"boolean", | ||
"null" | ||
], | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"lookup", | ||
"name", | ||
"type" | ||
], | ||
"type": "object" | ||
}, | ||
"value": { | ||
"additionalProperties": false, | ||
"description": "Value lookup and name definition", | ||
"properties": { | ||
"lookup": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"type": { | ||
"description": "Possible types, defined by JSON Schema type names", | ||
"enum": [ | ||
"string", | ||
"number", | ||
"integer", | ||
"object", | ||
"array", | ||
"boolean", | ||
"null" | ||
], | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"lookup", | ||
"name", | ||
"type" | ||
], | ||
"type": "object" | ||
} | ||
}, | ||
"required": [ | ||
"key", | ||
"value" | ||
], | ||
"type": "object" | ||
}, | ||
"series": { | ||
"description": "Chart data series of key-value objects", | ||
"items": { | ||
"additionalProperties": false, | ||
"description": "Key-value list item object", | ||
"properties": { | ||
"key": { | ||
"type": [ | ||
"string", | ||
"number", | ||
"integer", | ||
"object", | ||
"array", | ||
"boolean", | ||
"null" | ||
] | ||
}, | ||
"value": { | ||
"type": [ | ||
"string", | ||
"number", | ||
"integer", | ||
"object", | ||
"array", | ||
"boolean", | ||
"null" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"key", | ||
"value" | ||
], | ||
"type": "object" | ||
}, | ||
"maxItems": 1000, | ||
"minItems": 1, | ||
"type": "array" | ||
} | ||
}, | ||
"required": [ | ||
"definition", | ||
"series" | ||
], | ||
"type": "object" | ||
}, | ||
"title": { | ||
"description": "Title of the chart", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"chartType", | ||
"data", | ||
"title" | ||
], | ||
"type": "object" | ||
} |
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,14 @@ | ||
[ | ||
{ | ||
"name": "Bev\u00f6lkerungz\u00e4hlung Anhalt 2021", | ||
"url": "https://wam.rl-institut.de/digiplan/sources#11" | ||
}, | ||
{ | ||
"name": "Bev\u00f6lkerungsprognose Anhalt 2030", | ||
"url": "https://wam.rl-institut.de/digiplan/sources#12" | ||
}, | ||
{ | ||
"name": "Bev\u00f6lkerungsprognose Anhalt 2050", | ||
"url": "https://wam.rl-institut.de/digiplan/sources#13" | ||
} | ||
] |
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,25 @@ | ||
{ | ||
"$id": "https://wam.rl-institut.de/digiplan/schemas/components/sources.schema.json", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"description": "List of data sources", | ||
"items": { | ||
"additionalProperties": false, | ||
"description": "Name and URL (IRI) of data source", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"url": { | ||
"description": "identifier can be either URI or IRI (IRI is superset of URI). More info: https://json-schema.org/understanding-json-schema/reference/string.html#id7", | ||
"format": "iri", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"name", | ||
"url" | ||
], | ||
"type": "object" | ||
}, | ||
"type": "array" | ||
} |
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,52 @@ | ||
{ | ||
"chart": { | ||
"chartType": "bar", | ||
"data": { | ||
"definition": { | ||
"key": { | ||
"lookup": "year", | ||
"name": "Year", | ||
"type": "integer" | ||
}, | ||
"value": { | ||
"lookup": "population", | ||
"name": "Population", | ||
"type": "integer" | ||
} | ||
}, | ||
"series": [ | ||
{ | ||
"key": 2022, | ||
"value": 9311 | ||
}, | ||
{ | ||
"key": 2030, | ||
"value": 9182 | ||
}, | ||
{ | ||
"key": 2045, | ||
"value": 8903 | ||
} | ||
] | ||
}, | ||
"title": "Population Forecast" | ||
}, | ||
"description": "The population in 2022 of Z\u00f6rbig was 9,311 inhabitants. The entire ABW region had 370,190 inhabitants at that time. The following chart shows a forecast of the population development for the years 2022, 2030, and 2045.", | ||
"id": 12, | ||
"municipality": "Z\u00f6rbig", | ||
"sources": [ | ||
{ | ||
"name": "Bev\u00f6lkerungz\u00e4hlung Anhalt 2021", | ||
"url": "https://wam.rl-institut.de/digiplan/sources#11" | ||
}, | ||
{ | ||
"name": "Bev\u00f6lkerungsprognose Anhalt 2030", | ||
"url": "https://wam.rl-institut.de/digiplan/sources#12" | ||
}, | ||
{ | ||
"name": "Bev\u00f6lkerungsprognose Anhalt 2050", | ||
"url": "https://wam.rl-institut.de/digiplan/sources#13" | ||
} | ||
], | ||
"title": "Population" | ||
} |
Oops, something went wrong.