Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 7509dfc

Browse files
committed
Fixed some pep8 and pyflakes stuff. Added more data keyword testing
1 parent b2b5892 commit 7509dfc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

documentcloud/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def put(self, method, params):
123123
urllib.parse.quote_plus(key.encode("utf-8")),
124124
urllib.parse.quote_plus(value.encode("utf-8"))
125125
) for key, value in
126-
string_data.items()
126+
data.items()
127127
])
128128
else:
129129
# Otherwise, we can just use the vanilla urllib prep method
@@ -629,6 +629,7 @@ def validate_value(self, value):
629629
if not isinstance(value, six.string_types):
630630
raise TypeError("data attribute values must be strings")
631631

632+
632633
class Document(BaseAPIObject):
633634
"""
634635
A document returned by the API.

tests/test_all.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,17 @@ def test_private_actions(self):
346346
self.assertRaises(ValueError, setattr, obj, "data", {key: 'foo'})
347347
obj.data = dict(boom='bap')
348348

349+
# Test to make sure non-strings can't get into the data dictionary
350+
with self.assertRaises(TypeError):
351+
obj.data = dict(a=1)
352+
353+
with self.assertRaises(TypeError):
354+
obj.data = {1: 'a'}
355+
356+
obj.data = dict(boom='bap')
357+
with self.assertRaises(TypeError):
358+
obj.data[1] = 2
359+
349360
# Resources
350361
self.assertEqual(obj.published_url, obj.resources.published_url)
351362
self.assertEqual(obj.related_article, obj.resources.related_article)

0 commit comments

Comments
 (0)