Skip to content

Commit

Permalink
Tests for missing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
simonharrer committed Mar 13, 2024
1 parent 0245c7f commit 681868b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/examples/examples/datacontract_missing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
dataContractSpecification: 0.9.2
id: "61111-0002"
info:
title: "Verbraucherpreisindex: Deutschland, Monate"
description: A data contract for the distribution and use of the German Consumer Price Index data.
version: 1.0.0
owner: my-domain-team
models:
verbraucherpreisindex:
description: Model representing the Consumer Price Index for Germany
fields:
wert:
description: Value of the Consumer Price Index
type: bigint # integer
required: true
jahrMonat:
description: Year and month of the data
type: varchar # string
required: true
qualitaet:
description: Quality of the data
type: varchar # string
enum:
- "vorlaeufig"
- "endgueltig"
25 changes: 25 additions & 0 deletions tests/test_examples_examples_missing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import logging

from typer.testing import CliRunner

from datacontract.cli import app
from datacontract.data_contract import DataContract

runner = CliRunner()

logging.basicConfig(level=logging.DEBUG, force=True)


def test_cli():
result = runner.invoke(app, ["test", "--examples", "./examples/examples/datacontract_missing.yaml"])
assert result.exit_code == 1


def test_missing():
data_contract = DataContract(data_contract_file="examples/examples/datacontract_missing.yaml", examples=True)
run = data_contract.test()
print(run)
print(run.result)
assert run.result == "warning"


0 comments on commit 681868b

Please sign in to comment.