|
11 | 11 | ) |
12 | 12 | from odin.utils import getmeta, snake_to_camel |
13 | 13 |
|
14 | | -from .resources import Book, BookProxy, InheritedCamelCaseResource, Library, Subscriber |
| 14 | +from .resources import ( |
| 15 | + Book, |
| 16 | + BookProxy, |
| 17 | + InheritedCamelCaseResource, |
| 18 | + Library, |
| 19 | + Subscriber, |
| 20 | + AltBook, |
| 21 | +) |
15 | 22 |
|
16 | 23 |
|
17 | 24 | class Author(odin.Resource): |
@@ -226,6 +233,14 @@ def test_use_a_reserved_field(self): |
226 | 233 | class InvalidFieldsResource(Resource): |
227 | 234 | fields = odin.StringField() |
228 | 235 |
|
| 236 | + def test_shadow_fields_are_identified(self): |
| 237 | + target = getmeta(AltBook) |
| 238 | + |
| 239 | + actual = target.shadow_fields |
| 240 | + |
| 241 | + assert isinstance(actual, tuple) |
| 242 | + assert [f.name for f in actual] == ["title"] |
| 243 | + |
229 | 244 |
|
230 | 245 | class TestConstructionMethods: |
231 | 246 | def test_build_object_graph_empty_dict_no_clean(self): |
@@ -393,3 +408,13 @@ def test_field_name_format(self): |
393 | 408 | actual = [field.name for field in options.fields] |
394 | 409 |
|
395 | 410 | assert actual == ["fullName", "yearOfBirth", "emailAddress"] |
| 411 | + |
| 412 | + def test_shadowing(self): |
| 413 | + actual = AltBook(title="Foo", isbn="123456") |
| 414 | + |
| 415 | + getmeta(actual) |
| 416 | + |
| 417 | + book = Book(title="Foo", isbn="123456") |
| 418 | + |
| 419 | + assert book.isbn == "123456" |
| 420 | + assert book.title == "Foo" |
0 commit comments