Skip to main content

Testframework voor VERA referentiedata

Project description

VERA Testframework

⏳ Work in progress

Maakt het makkelijk om te testen of data voldoet aan de VERA-standaard m.b.v. het pyspark-testframework.

Tutorial

Op het moment is het vera-testframework alleen compatibel met pyspark.

from vera_testframework.pyspark import ReferentiedataTest
from pyspark.sql import SparkSession
from testframework.dataquality import DataFrameTester
spark = SparkSession.builder.appName("vera_testframework").getOrCreate()

Hieronder wordt een voorbeeld DataFrame gemaakt m.b.t. ruimten, waarvan we gaan testen of de waardes voldoen aan de VERA-standaard.

ruimten = [
    (1, "LOG", "Loggia"),
    (2, "WOO", "Woonkamer"),
    (3, "BAD", "Badruimte"),
    (4, "BAD", "Badkamer"),
    (5, None, "Kelder"),
    (6, "SLA", None),
]

ruimten_df = spark.createDataFrame(ruimten, ["id", "code", "naam"])

We maken gebruik van de DataFrameTester van het pyspark-testframework om onze testresultaten in bij te houden.

testframework = DataFrameTester(
    df=ruimten_df,
    primary_key="id",
    spark=spark,
)

Door middel van de ReferentiedataTest kunnen we testen of een kolom voldoet aan de VERA-standaard m.b.t. Referentiedata.

testframework.test(
    col="code",
    test=ReferentiedataTest(
        soort="RUIMTEDETAILSOORT",
        attribuut="Code",
        release="latest",  # standaard is latest, maar kan ook een specifieke versie zijn zoals v4.1.240419
    ),
    nullable=False,  # of een waarde leeg mag zijn. Dit is aan de gebruiker
).show(truncate=False)
+-----------+----------------------------------------+-----------+----------+----------------------------------+--------+
|primary_key|test_name                               |test_result|test_value|test_description                  |test_col|
+-----------+----------------------------------------+-----------+----------+----------------------------------+--------+
|1          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |LOG       |VERA_LATEST_RUIMTEDETAILSOORT_Code|code    |
|2          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |WOO       |VERA_LATEST_RUIMTEDETAILSOORT_Code|code    |
|3          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |BAD       |VERA_LATEST_RUIMTEDETAILSOORT_Code|code    |
|4          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |BAD       |VERA_LATEST_RUIMTEDETAILSOORT_Code|code    |
|5          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|false      |NULL      |VERA_LATEST_RUIMTEDETAILSOORT_Code|code    |
|6          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |SLA       |VERA_LATEST_RUIMTEDETAILSOORT_Code|code    |
+-----------+----------------------------------------+-----------+----------+----------------------------------+--------+
testframework.test(
    col="naam",
    test=ReferentiedataTest(
        soort="RUIMTEDETAILSOORT",
        attribuut="Naam",
    ),
    nullable=True,
    description="Naam van ruimtedetailsoort voldoet aan de VERA-standaard"
).show(truncate=False)
+-----------+----------------------------------------+-----------+----------+--------------------------------------------------------+--------+
|primary_key|test_name                               |test_result|test_value|test_description                                        |test_col|
+-----------+----------------------------------------+-----------+----------+--------------------------------------------------------+--------+
|1          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |Loggia    |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |
|2          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |Woonkamer |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |
|3          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|false      |Badruimte |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |
|4          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |Badkamer  |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |
|5          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |Kelder    |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |
|6          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |NULL      |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |
+-----------+----------------------------------------+-----------+----------+--------------------------------------------------------+--------+

De resultaten van de testen zijn te vinden in de .results attribuut van de DataFrameTester.

testframework.results.show(truncate=False)
+-----------+----------------------------------------+-----------+----------+--------------------------------------------------------+--------+---------------+-----------------------+
|primary_key|test_name                               |test_result|test_value|test_description                                        |test_col|primary_key_col|timestamp              |
+-----------+----------------------------------------+-----------+----------+--------------------------------------------------------+--------+---------------+-----------------------+
|1          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |LOG       |VERA_LATEST_RUIMTEDETAILSOORT_Code                      |code    |id             |2025-10-21 15:58:35.475|
|2          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |WOO       |VERA_LATEST_RUIMTEDETAILSOORT_Code                      |code    |id             |2025-10-21 15:58:35.475|
|3          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |BAD       |VERA_LATEST_RUIMTEDETAILSOORT_Code                      |code    |id             |2025-10-21 15:58:35.475|
|4          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |BAD       |VERA_LATEST_RUIMTEDETAILSOORT_Code                      |code    |id             |2025-10-21 15:58:35.475|
|5          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|false      |NULL      |VERA_LATEST_RUIMTEDETAILSOORT_Code                      |code    |id             |2025-10-21 15:58:35.475|
|6          |code__VERA_LATEST_RUIMTEDETAILSOORT_Code|true       |SLA       |VERA_LATEST_RUIMTEDETAILSOORT_Code                      |code    |id             |2025-10-21 15:58:35.475|
|1          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |Loggia    |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |id             |2025-10-21 15:58:35.475|
|2          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |Woonkamer |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |id             |2025-10-21 15:58:35.475|
|3          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|false      |Badruimte |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |id             |2025-10-21 15:58:35.475|
|4          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |Badkamer  |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |id             |2025-10-21 15:58:35.475|
|5          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |Kelder    |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |id             |2025-10-21 15:58:35.475|
|6          |naam__VERA_LATEST_RUIMTEDETAILSOORT_Naam|true       |NULL      |Naam van ruimtedetailsoort voldoet aan de VERA-standaard|naam    |id             |2025-10-21 15:58:35.475|
+-----------+----------------------------------------+-----------+----------+--------------------------------------------------------+--------+---------------+-----------------------+

Voor meer informatie over hoe het pyspark-testframework te gebruiken, raadpleeg de documentatie op hun Github

spark.stop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vera_testframework-1.0.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vera_testframework-1.0.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file vera_testframework-1.0.0.tar.gz.

File metadata

  • Download URL: vera_testframework-1.0.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vera_testframework-1.0.0.tar.gz
Algorithm Hash digest
SHA256 de00af1dbdf080d4f61fb25d36d3cf36ae4cc5f26329547f83f9190425c449c0
MD5 c73175029ad24e699af39158892a6faa
BLAKE2b-256 dc36bee4f43003bf7dc421994ddf690cd025800315e5c45708cde8b4e2f681a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for vera_testframework-1.0.0.tar.gz:

Publisher: publish-to-pypi.yml on woonstadrotterdam/vera-testframework

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vera_testframework-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vera_testframework-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1265e8695b1ea351d858f11f6e461d42e0a16b24ec4b607ff92a7e7030aab840
MD5 7438bbfeca991046a04fc555164ebb5f
BLAKE2b-256 fbe581e3cc5b9999ad97700fc0a952fbcdbc035ff055eff78a8f377447ec1ac5

See more details on using hashes here.

Provenance

The following attestation bundles were made for vera_testframework-1.0.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on woonstadrotterdam/vera-testframework

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page