Skip to content

Commit

Permalink
#250: Add tests for OpenAPI type conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Aug 13, 2021
1 parent 4a3cf7e commit b946467
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/test_openapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from datetime import date, datetime

import pytest

from datagateway_api.src.resources.entities.entity_map import type_conversion


class TestOpenAPI:
@pytest.mark.parametrize(
"python_type, expected_type",
[
pytest.param(int, {"type": "integer"}, id="integer"),
pytest.param(float, {"type": "number", "format": "float"}, id="float"),
pytest.param(bool, {"type": "boolean"}, id="boolean"),
pytest.param(
datetime, {"type": "string", "format": "datetime"}, id="datetime",
),
pytest.param(date, {"type": "string", "format": "date"}, id="date"),
pytest.param(str, {"type": "string"}, id="string"),
],
)
def test_type_conversion(self, python_type, expected_type):
openapi_type = type_conversion(python_type)
assert openapi_type == expected_type

0 comments on commit b946467

Please sign in to comment.