Permalink
Browse files

Make GenericObject more amenable to optional fields, clarify docs (bu…

…g 859562)
  • Loading branch information...
1 parent be53589 commit 9752f2b1f51d7660f68bafa4306d4f40f56ad892 @chuckharmston chuckharmston committed Apr 10, 2013
Showing with 15 additions and 1 deletion.
  1. +7 −0 docs/topics/api/misc.rst
  2. +4 −0 mkt/account/tests/test_api.py
  3. +4 −1 mkt/api/base.py
View
@@ -154,6 +154,13 @@ Feedback
**Request**
+ :param chromeless: (optional) "Yes" or "No", indicating whether the user
+ agent sending the feedback is chromeless.
+ :param feedback: (required) the text of the feedback.
+ :param from_url: (optional) the URL from which the feedback was sent.
+ :param platform: (optional) a description of the platform from which the
+ feedback is being sent.
+
.. code-block:: json
{
@@ -241,6 +241,10 @@ def test_send_potato(self):
self._test_bad_api_potato_data(tuber_res, tuber_data)
self._test_bad_api_potato_data(potato_res, potato_data)
+ def test_missing_optional_field(self):
+ res, data = self._call(data={'platform': None})
+ eq_(201, res.status_code)
+
def test_send_bad_data(self):
"""
One test to ensure that FeedbackForm is doing its validation duties.
View
@@ -296,7 +296,10 @@ class GenericObject(dict):
subclass.
"""
def __getattr__(self, name):
- return self.__getitem__(name)
+ try:
+ return self.__getitem__(name)
+ except KeyError:
+ return None
def __setattr__(self, name, value):
self.__setitem__(name, value)

0 comments on commit 9752f2b

Please sign in to comment.