From 7e1eee53899c73d32ebacf8596b1866ce40a0378 Mon Sep 17 00:00:00 2001 From: christina Date: Sat, 4 May 2024 20:31:34 +0200 Subject: [PATCH] test: check validation function of PlaneEmissionParameters --- tests/unit/test_parameters.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/unit/test_parameters.py diff --git a/tests/unit/test_parameters.py b/tests/unit/test_parameters.py new file mode 100644 index 0000000..28748a4 --- /dev/null +++ b/tests/unit/test_parameters.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""Test pydantic models in parameters.py""" + +from co2calculator import TransportationMode +from co2calculator.parameters import PlaneEmissionParameters +import pytest +from pydantic import ValidationError + + +def test_planeemissionparameter_raise_validation_error(): + """Tests that PlaneEmissionParameters raises a validation error when an invalid seating is provided.""" + with pytest.raises(ValidationError): + PlaneEmissionParameters(subcategory=TransportationMode.PLANE, seating="INVALID")