Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
test: clarify where we mean IRouter vs db.Router
Browse files Browse the repository at this point in the history
  • Loading branch information
pjenvey committed Aug 26, 2016
1 parent 2f783fe commit 3324405
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions autopush/tests/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _check_error(self, code, errno, error=None, message=None):

def test_uaid_lookup_results(self):
fresult = dict(router_type="test")
frouter = Mock(spec=Router)
frouter = Mock(spec=IRouter)
frouter.route_notification = Mock()
frouter.route_notification.return_value = RouterResponse()
self.endpoint.chid = dummy_chid
Expand All @@ -234,7 +234,7 @@ def handle_finish(value):

def test_uaid_lookup_results_bad_ttl(self):
fresult = dict(router_type="test")
frouter = Mock(spec=Router)
frouter = Mock(spec=IRouter)
frouter.route_notification = Mock()
frouter.route_notification.return_value = RouterResponse()
self.endpoint.chid = dummy_chid
Expand All @@ -253,7 +253,7 @@ def handle_finish(value):
def test_webpush_ttl_too_large(self):
from autopush.endpoint import MAX_TTL
fresult = dict(router_type="test")
frouter = Mock(spec=Router)
frouter = Mock(spec=IRouter)
frouter.route_notification = Mock()
frouter.route_notification.return_value = RouterResponse()
self.endpoint.chid = dummy_chid
Expand All @@ -274,7 +274,7 @@ def handle_finish(value):

def test_webpush_missing_ttl(self):
del(self.request_mock.headers['ttl'])
frouter = Mock(spec=Router)
frouter = Mock(spec=IRouter)
frouter.route_notification = Mock()
frouter.route_notification.return_value = RouterResponse()
self.endpoint.ap_settings.routers["webpush"] = frouter
Expand Down Expand Up @@ -372,7 +372,7 @@ def handle_finish(value):
# ...And for other router types.
def test_other_uaid_lookup_no_crypto_headers(self):
fresult = dict(router_type="test")
frouter = Mock(spec=Router)
frouter = Mock(spec=IRouter)
frouter.route_notification = Mock()
frouter.route_notification.return_value = RouterResponse()
self.endpoint.chid = dummy_chid
Expand Down Expand Up @@ -1435,7 +1435,7 @@ def setUp(self):
self.storage_mock = settings.storage = Mock(spec=Storage)
self.router_mock.register_user = Mock()
self.router_mock.register_user.return_value = (True, {}, {})
settings.routers["test"] = self.router_mock
settings.routers["test"] = Mock(spec=IRouter)

self.request_mock = Mock(body=b'', arguments={}, headers={})
self.reg = endpoint.RegistrationHandler(Application(),
Expand Down Expand Up @@ -1552,7 +1552,6 @@ def test_cors_options(self):

@patch('uuid.uuid4', return_value=uuid.UUID(dummy_uaid))
def test_post(self, *args):
self.reg.ap_settings.routers["test"] = self.router_mock
self.reg.request.body = json.dumps(dict(
type="simplepush",
channelID=dummy_chid,
Expand Down Expand Up @@ -1803,13 +1802,14 @@ def handle_finish(value):
@patch('uuid.uuid4', return_value=uuid.UUID(dummy_chid))
def test_put(self, *args):
data = dict(token="some_token")
self.router_mock.register = Mock()
self.router_mock.register.return_value = data
frouter = self.reg.ap_settings.routers["test"]
frouter.register = Mock()
frouter.register.return_value = data
self.reg.request.body = json.dumps(data)

def handle_finish(value):
self.reg.write.assert_called_with({})
self.router_mock.register.assert_called_with(
frouter.register.assert_called_with(
dummy_uaid, data, uri=self.reg.request.uri
)

Expand Down

0 comments on commit 3324405

Please sign in to comment.