Skip to content

Commit 6a61379

Browse files
committed
refactor: rename 'meta' to 'metadata' in response models for consistency
1 parent f60faf9 commit 6a61379

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

fastapi-base/tests/test_schemas.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@ class TestIResponseBase:
2525
def test_response_base_with_string_data(self):
2626
"""Test IResponseBase with string data"""
2727
response = IResponseBase[str](
28-
message="Success", data="Hello World", meta={"version": "1.0"}
28+
message="Success", data="Hello World", metadata={"version": "1.0"}
2929
)
3030

3131
assert response.message == "Success"
3232
assert response.data == "Hello World"
33-
assert response.meta == {"version": "1.0"}
33+
assert response.metadata == {"version": "1.0"}
3434

3535
def test_response_base_with_user_model(self):
3636
"""Test IResponseBase with custom model"""
3737
user = User(id=1, name="John Doe", email="john@example.com")
3838
response = IResponseBase[User](
39-
message="User found", data=user, meta={"timestamp": "2023-01-01"}
39+
message="User found", data=user, metadata={"timestamp": "2023-01-01"}
4040
)
4141

4242
assert response.message == "User found"
4343
assert response.data == user
4444
assert response.data.name == "John Doe"
45-
assert response.meta["timestamp"] == "2023-01-01"
45+
assert response.metadata["timestamp"] == "2023-01-01"
4646

4747
def test_response_base_with_list_data(self):
4848
"""Test IResponseBase with list of models"""
@@ -62,7 +62,7 @@ def test_response_base_defaults(self):
6262
response = IResponseBase[str]()
6363

6464
assert response.message == ""
65-
assert response.meta == {}
65+
assert response.metadata == {}
6666
assert response.data is None
6767

6868
def test_response_base_with_none_data(self):
@@ -80,7 +80,7 @@ def test_response_base_serialization(self):
8080
json_data = response.model_dump()
8181
expected = {
8282
"message": "Success",
83-
"meta": {"count": 1},
83+
"metadata": {"count": 1},
8484
"data": {"id": 1, "name": "John", "email": "john@example.com"},
8585
}
8686

@@ -147,12 +147,12 @@ def test_post_response_with_meta(self):
147147
"""Test POST response with metadata"""
148148
user = User(id=1, name="John", email="john@example.com")
149149
response = IPostResponseBase[User](
150-
data=user, meta={"created_at": "2023-01-01", "version": "1.0"}
150+
data=user, metadata={"created_at": "2023-01-01", "version": "1.0"}
151151
)
152152

153153
assert response.message == "Data created correctly"
154154
assert response.data == user
155-
assert response.meta["created_at"] == "2023-01-01"
155+
assert response.metadata["created_at"] == "2023-01-01"
156156

157157

158158
class TestResponseModelsIntegration:
@@ -176,7 +176,7 @@ def test_nested_generic_types(self):
176176
User(id=2, name="Jane", email="jane@example.com"),
177177
]
178178

179-
response = IGetResponseBase[List[User]](data=users, meta={"total": 2, "page": 1})
179+
response = IGetResponseBase[List[User]](data=users, metadata={"total": 2, "page": 1})
180180

181181
assert isinstance(response.data, list)
182182
assert len(response.data) == 2
@@ -191,7 +191,7 @@ def test_response_inheritance_chain(self):
191191

192192
# Should have all attributes from base class
193193
assert hasattr(get_response, "message")
194-
assert hasattr(get_response, "meta")
194+
assert hasattr(get_response, "metadata")
195195
assert hasattr(get_response, "data")
196196

197197
# Should be instance of both
@@ -211,11 +211,11 @@ def test_invalid_data_type(self):
211211
)
212212

213213
def test_meta_must_be_dict(self):
214-
"""Test that meta must be a dictionary"""
214+
"""Test that metadata must be a dictionary"""
215215
with pytest.raises(ValidationError): # Pydantic validation error
216216
IResponseBase[str](
217217
message="Test",
218-
meta="not a dict", # Wrong type
218+
metadata="not a dict", # Wrong type
219219
)
220220

221221
def test_message_must_be_string(self):

0 commit comments

Comments
 (0)