Skip to content

Commit

Permalink
Unit test code previously covered in passing
Browse files Browse the repository at this point in the history
  • Loading branch information
evansd committed Aug 9, 2022
1 parent b884a62 commit 759902e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/unit/contracts/test_base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime

import pytest

from databuilder.backends.base import BaseBackend, Column, MappedTable
Expand Down Expand Up @@ -88,3 +90,33 @@ class BadBackend(BaseBackend):
match="Column date_of_birth is defined with an invalid type 'integer'.\n\nAllowed types are: date",
):
PatientsContract.validate_implementation(BadBackend, "patients")


def test_validate_schema():
PatientsContract.validate_schema(
{
"sex": str,
"date_of_birth": datetime.date,
}
)


def test_validate_schema_wrong_columns():
with pytest.raises(AssertionError):
PatientsContract.validate_schema(
{
"sex": str,
"date_of_birth": datetime.date,
"extra_column": int,
}
)


def test_validate_schema_wrong_types():
with pytest.raises(AssertionError):
PatientsContract.validate_schema(
{
"sex": str,
"date_of_birth": str,
}
)

0 comments on commit 759902e

Please sign in to comment.