Skip to content

Commit 9de3754

Browse files
author
David Andersson
committed
add check for spec_str
1 parent b4f2549 commit 9de3754

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

open_alchemy/build/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,16 @@ def calculate_version(*, spec: typing.Any, schemas: types.Schemas) -> TVersion:
159159

160160
@dataclasses.dataclass
161161
class TSpecInfo:
162-
"""Information about the spec."""
162+
"""
163+
Information about the spec.
164+
165+
Attrs:
166+
version: Unique identifier for this instance.
167+
spec_str: The string representation.
168+
title: A name describing the spec.
169+
description: More detailed summary of the spec.
170+
171+
"""
163172

164173
version: TVersion
165174
spec_str: TSpecStr
@@ -169,7 +178,7 @@ class TSpecInfo:
169178

170179
def calculate_spec_info(*, schemas: types.Schemas, spec: typing.Any) -> TSpecInfo:
171180
"""
172-
Calculate the information about the spec.
181+
Calculate information about the spec.
173182
174183
Args:
175184
schemas: The schemas from the spec.

tests/open_alchemy/test_build.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def test_generate_spec_str(schemas, version, title, description, expected_spec_s
121121
@pytest.mark.build
122122
def test_calculate_spec_info_version():
123123
"""
124-
GIVEN spec with version
124+
GIVEN spec
125125
WHEN calculate_spec_info is called with the spec
126126
THEN the version is returned.
127127
"""
@@ -133,6 +133,24 @@ def test_calculate_spec_info_version():
133133
assert spec_info.version == "63581fa2bdc5cef14183"
134134

135135

136+
@pytest.mark.build
137+
def test_calculate_spec_info_spec_str():
138+
"""
139+
GIVEN spec
140+
WHEN calculate_spec_info is called with the spec
141+
THEN the string representation of it is returned.
142+
"""
143+
spec = {}
144+
schemas = {}
145+
146+
spec_info = build.calculate_spec_info(spec=spec, schemas=schemas)
147+
148+
assert (
149+
spec_info.spec_str
150+
== '{"info":{"version":"63581fa2bdc5cef14183"},"components":{"schemas":{}}}'
151+
)
152+
153+
136154
@pytest.mark.parametrize(
137155
"info, expected_title",
138156
[

0 commit comments

Comments
 (0)