Skip to content
Browse files

tests.unit: Add tests for JsonRequester.__init__

  • Loading branch information...
1 parent cf7d2a7 commit eaf78cf38e1d63c773b2a4d335b5e9ce20834c89 @patrick-smith patrick-smith committed Jan 23, 2012
Showing with 50 additions and 1 deletion.
  1. +1 −0 requirements.pip
  2. +49 −1 tests/unit/test_json_requestor.py
View
1 requirements.pip
@@ -1,4 +1,5 @@
coverage
+deterministic_dingus
dingus
httplib2
nose
View
50 tests/unit/test_json_requestor.py
@@ -1,8 +1,9 @@
import datetime
-from dingus import Dingus
+from deterministic_dingus import Dingus, DingusWhitelistTestCase
from jsonrequester import *
+import jsonrequester as mod
DATE = datetime.datetime(2000, 01, 01, 01, 00, 00)
@@ -18,3 +19,50 @@ def when_serializing_datetime_should_return_isoformat():
def when_serializing_unknown_type_should_stringify():
obj = Dingus('obj')
assert default_serializer(obj) == str(obj)
+
+
+####
+##
+## JsonRequester.__init__
+##
+####
+
+class BaseCreatingJsonRequester(DingusWhitelistTestCase):
+
+ module = mod
+ module_mocks = ['httplib2']
+ additional_mocks = ['url']
+
+ def setup(self):
+ DingusWhitelistTestCase.setup(self)
+
+ def should_set_base_url(self):
+ assert self.json_requester.base_url == self.url
+
+ def should_set_http(self):
+ assert self.json_requester.http is self.module.httplib2.Http()
+
+
+class WhenCreatingJsonRequesterWithDefaults(BaseCreatingJsonRequester):
+
+ def setup(self):
+ BaseCreatingJsonRequester.setup(self)
+
+ self.json_requester = JsonRequester(self.url)
+
+ def should_set_serializer_to_default_serializer(self):
+ assert self.json_requester.serializer is default_serializer
+
+
+class WhenCreatingJsonRequesterWithSerializer(BaseCreatingJsonRequester):
+
+ additional_mocks = ['serializer']
+
+ def setup(self):
+ BaseCreatingJsonRequester.setup(self)
+
+ self.json_requester = JsonRequester(
+ self.url, serializer=self.serializer)
+
+ def should_set_serializer(self):
+ assert self.json_requester.serializer == self.serializer

0 comments on commit eaf78cf

Please sign in to comment.
Something went wrong with that request. Please try again.