summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2016-05-12 19:31:16 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2016-05-24 23:24:07 (GMT)
commitf9bd3fb0cc112691da490022effe0131a2a14d40 (patch)
treeeb985b37fed91d88ab526cc6d80d2230c948d80d /tests
parentda768271bf738816c5fb4e7413857c8eaeaf251a (diff)
downloadpublik-bi-f9bd3fb0cc112691da490022effe0131a2a14d40.zip
publik-bi-f9bd3fb0cc112691da490022effe0131a2a14d40.tar.gz
publik-bi-f9bd3fb0cc112691da490022effe0131a2a14d40.tar.bz2
bi-joe: BI engine and frontend for PostgreSQL
Diffstat (limited to 'tests')
-rw-r--r--tests/test_bijoe_schemas.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/test_bijoe_schemas.py b/tests/test_bijoe_schemas.py
new file mode 100644
index 0000000..9b426d5
--- /dev/null
+++ b/tests/test_bijoe_schemas.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+from bijoe.schemas import Warehouse
+
+
+def test_simple_parsing():
+ Warehouse.from_json({
+ 'name': 'coin',
+ 'label': 'coin',
+ 'pg_dsn': 'dbname=zozo',
+ 'search_path': ['cam', 'public'],
+ 'cubes': [
+ {
+ 'name': 'all_formdata',
+ 'label': 'Tous les formulaires',
+ 'fact_table': 'formdata',
+ 'key': 'id',
+ 'joins': [
+ {
+ 'name': 'formdef',
+ 'master': '{fact_table}.formdef_id',
+ 'table': 'formdef',
+ 'detail': 'formdef.id',
+ }
+ ],
+ 'dimensions': [
+ {
+ 'label': 'formulaire',
+ 'name': 'formdef',
+ 'type': 'integer',
+ 'join': ['formdef'],
+ 'value': 'formdef.id',
+ 'value_label': 'formdef.label',
+ 'order_by': 'formdef.label'
+ },
+ {
+ 'name': 'receipt_time',
+ 'label': 'date de soumission',
+ 'join': ['receipt_time'],
+ 'type': 'date',
+ 'value': 'receipt_time.date'
+ }
+ ],
+ 'measures': [
+ {
+ 'type': 'integer',
+ 'label': 'Nombre de demandes',
+ 'expression': 'count({fact_table}.id)',
+ 'name': 'count'
+ },
+ {
+ 'type': 'integer',
+ 'label': u'Délai de traitement',
+ 'expression': 'avg((to_char(endpoint_delay, \'9999.999\') || \' days\')::interval)',
+ 'name': 'avg_endpoint_delay'
+ },
+ {
+ 'type': 'percent',
+ 'label': 'Pourcentage',
+ 'expression': 'count({fact_table}.id) * 100. / (select count({fact_table}.id) from {table_expression} where {where_conditions})',
+ 'name': 'percentage'
+ }
+ ]
+ }
+ ],
+ })