Skip to content

Commit 5cbc800

Browse files
committed
test: check against strings using period as delimiter
1 parent 5fa736a commit 5cbc800

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

end_to_end_tests/golden-record/my_test_api_client/models/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .import_ import Import
2424
from .model_from_all_of import ModelFromAllOf
2525
from .model_name import ModelName
26+
from .model_reference_with_periods import ModelReferenceWithPeriods
2627
from .model_with_additional_properties_inlined import ModelWithAdditionalPropertiesInlined
2728
from .model_with_additional_properties_inlined_additional_property import (
2829
ModelWithAdditionalPropertiesInlinedAdditionalProperty,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from typing import Any, Dict, List, Type, TypeVar
2+
3+
import attr
4+
5+
T = TypeVar("T", bound="ModelReferenceWithPeriods")
6+
7+
8+
@attr.s(auto_attribs=True)
9+
class ModelReferenceWithPeriods:
10+
"""A Model with periods in its reference"""
11+
12+
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
13+
14+
def to_dict(self) -> Dict[str, Any]:
15+
16+
field_dict: Dict[str, Any] = {}
17+
field_dict.update(self.additional_properties)
18+
field_dict.update({})
19+
20+
return field_dict
21+
22+
@classmethod
23+
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
24+
d = src_dict.copy()
25+
model_reference_with_periods = cls()
26+
27+
model_reference_with_periods.additional_properties = d
28+
return model_reference_with_periods
29+
30+
@property
31+
def additional_keys(self) -> List[str]:
32+
return list(self.additional_properties.keys())
33+
34+
def __getitem__(self, key: str) -> Any:
35+
return self.additional_properties[key]
36+
37+
def __setitem__(self, key: str, value: Any) -> None:
38+
self.additional_properties[key] = value
39+
40+
def __delitem__(self, key: str) -> None:
41+
del self.additional_properties[key]
42+
43+
def __contains__(self, key: str) -> bool:
44+
return key in self.additional_properties

end_to_end_tests/openapi.json

+4
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,10 @@
18281828
},
18291829
"None": {
18301830
"type": "object"
1831+
},
1832+
"model.reference.with.Periods": {
1833+
"type": "object",
1834+
"description": "A Model with periods in its reference"
18311835
}
18321836
}
18331837
}

tests/test_utils.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def test_empty_is_prefixed(self):
4747
("Response200Okay", ["Response", "200", "Okay"]),
4848
("S3Config", ["S3", "Config"]),
4949
("s3config", ["s3config"]),
50+
("fully.qualified.Name", ["fully", "qualified", "Name"]),
5051
],
5152
)
5253
def test_split_words(before, after):
@@ -83,8 +84,8 @@ def test_kebab_case():
8384
assert utils.kebab_case("keep_alive") == "keep-alive"
8485

8586

86-
def test__sanitize():
87-
assert utils.sanitize("something*~with lots_- of weird things}=") == "somethingwith lots_- of weird things"
87+
def test_sanitize():
88+
assert utils.sanitize("some.thing*~with lots_- of weird things}=") == "some.thingwith lots_- of weird things"
8889

8990

9091
def test_no_string_escapes():

0 commit comments

Comments
 (0)