Skip to content

Commit a7e43fd

Browse files
author
Marshall Jones
committed
fix bug where we are trying to parse the meta field for uris
1 parent 97e66ad commit a7e43fd

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

balanced/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.11.3'
1+
__version__ = '0.11.4'
22
from collections import defaultdict
33
import contextlib
44

balanced/resources.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ def make_constructors():
385385
386386
"""
387387

388+
# these keys have key/value data but it should not be expanded into a
389+
# resource.
390+
NON_EXPANDABLE_KEYS = ['meta']
391+
388392
def the_new(cls, **kwargs):
389393
for key in kwargs.iterkeys():
390394

@@ -405,7 +409,7 @@ def the_init(self, **kwargs):
405409

406410
# iterate through the schema that comes back
407411
for key, value in kwargs.iteritems():
408-
if is_subresource(value):
412+
if key not in NON_EXPANDABLE_KEYS and is_subresource(value):
409413
# sub resources have a uri in them
410414
uri = value['uri']
411415
try:

balanced/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616

1717
_JSON_ERROR_MSG = (
18-
'Object of type {0} with value of {1} is not JSON serializable')
18+
'Object of type {0} with value of {1} is not JSON serializable'
19+
)
1920

2021

2122
def iter_multi_items(mapping):

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_wrap_raise_for_status(self):
139139

140140

141141
class TestConfigThread(threading.Thread):
142-
def __init__( self ):
142+
def __init__(self):
143143
threading.Thread.__init__(self)
144144
self.key = False
145145

tests/test_resource.py

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@ def test_redirects(self):
4141
self.assertEqual(
4242
exception.response.headers['location'],
4343
'/v1/your-mom'
44-
)
44+
)
45+
46+
def test_does_not_parse_meta(self):
47+
payload = {
48+
'uri': '/v1/yo-momma',
49+
'meta': {
50+
'uri': 'None',
51+
}
52+
}
53+
54+
balanced.Account(**payload)
4555

4656

4757
class TestPage(unittest.TestCase):
@@ -67,20 +77,22 @@ def test_filter2(self):
6777

6878
self.assertDictEqual(
6979
dict(parsed_qs),
70-
{'a': 'b',
71-
'a[!=]': '101',
72-
'b[<=]': '5',
73-
'b[<]': '4',
74-
'c[>=]': '44',
75-
'c[>]': '123',
76-
'd[!in]': '6,33,55',
77-
'd[in]': '1,2,3',
78-
'e[!contains]': 'soda',
79-
'e[contains]': 'it',
80-
'f[endswith]': 'lo',
81-
'f[startswith]': 'la',
82-
'g': '12',
83-
})
80+
{
81+
'a': 'b',
82+
'a[!=]': '101',
83+
'b[<=]': '5',
84+
'b[<]': '4',
85+
'c[>=]': '44',
86+
'c[>]': '123',
87+
'd[!in]': '6,33,55',
88+
'd[in]': '1,2,3',
89+
'e[!contains]': 'soda',
90+
'e[contains]': 'it',
91+
'f[endswith]': 'lo',
92+
'f[startswith]': 'la',
93+
'g': '12',
94+
}
95+
)
8496

8597
def test_sort(self):
8698
q = balanced.Marketplace.query

0 commit comments

Comments
 (0)