From 9d317e5b3ddcb17b8fc2140e19d74cd883563077 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Tue, 16 Feb 2016 03:24:42 -0500 Subject: [PATCH] Adds test for additional attributes on relations --- tests/test_fetching.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_fetching.py b/tests/test_fetching.py index 5c3c4913..6db73fa7 100644 --- a/tests/test_fetching.py +++ b/tests/test_fetching.py @@ -809,6 +809,26 @@ def test_additional_attributes(self): person = document['data'] assert person['attributes']['foo'] == 'bar' + def test_additional_attributes_not_related(self): + """Tests that we do not try to include additional attributes when + requesting a related resource. + + For more information, see pull request #257. + + """ + self.Article.foo = 'bar' + person = self.Person(id=1) + article = self.Article(id=1) + article.author = person + self.session.add_all([person, article]) + self.session.commit() + self.manager.create_api(self.Article, additional_attributes=['foo']) + self.manager.create_api(self.Person) + response = self.app.get('/api/article/1/author') + document = loads(response.data) + person = document['data'] + assert 'foo' not in person['attributes'] + def test_additional_attributes_callable(self): """Tests that callable attributes can be included using the ``additional_attributes`` keyword argument.