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

Commit

Permalink
fix: assertTrue -> ok_
Browse files Browse the repository at this point in the history
issue #674
  • Loading branch information
pjenvey committed Oct 4, 2016
1 parent e9fd8a1 commit db4e6dc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
46 changes: 23 additions & 23 deletions autopush/tests/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_delete_db_error(self):
ProvisionedThroughputExceededException(None, None)})

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.status_mock.assert_called_with(503, None)
self.finish_deferred.addCallback(handle_finish)

Expand Down Expand Up @@ -691,7 +691,7 @@ def test_put_default_router(self):
self.sp_router_mock.route_notification.return_value = RouterResponse()

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(200)
self.finish_deferred.addCallback(handle_finish)

Expand All @@ -714,7 +714,7 @@ def test_put_router_with_headers(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(200)

self.finish_deferred.addCallback(handle_finish)
Expand All @@ -733,7 +733,7 @@ def test_put_router_needs_change(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(500, None)
ru = self.router_mock.register_user
ok_(ru.called)
Expand All @@ -756,7 +756,7 @@ def test_put_router_needs_update(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(503, None)
self.router_mock.drop_user.assert_called()

Expand All @@ -782,7 +782,7 @@ def test_put_bogus_headers(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(400, None)

self.finish_deferred.addBoth(handle_finish)
Expand All @@ -806,7 +806,7 @@ def test_put_invalid_vapid_crypto_header(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(400, None)

self.finish_deferred.addCallback(handle_finish)
Expand All @@ -830,7 +830,7 @@ def test_put_invalid_vapid_crypto_key(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(401, None)

self.finish_deferred.addCallback(handle_finish)
Expand All @@ -854,7 +854,7 @@ def test_put_invalid_vapid_auth_header(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(401, None)

self.finish_deferred.addCallback(handle_finish)
Expand All @@ -876,7 +876,7 @@ def test_post_webpush_with_headers_in_response(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(201)
self.endpoint.set_header.assert_called_with(
"Location", "Somewhere")
Expand Down Expand Up @@ -929,7 +929,7 @@ def handle_finish(result, crypto_key, token):
for i in payload:
n = 'jwt_' + i
eq_(self.endpoint._client_info.get(n), payload[i])
self.assertTrue(result)
ok_(result)

self.finish_deferred.addCallback(handle_finish, crypto_key, token)
self.endpoint.post(None, dummy_uaid)
Expand Down Expand Up @@ -983,7 +983,7 @@ def test_post_webpush_with_other_than_vapid_auth(self):
def handle_finish(result):
self.endpoint.set_status.assert_called_with(201)
eq_(self.endpoint._client_info.get('jwt'), None)
self.assertTrue(result)
ok_(result)

self.finish_deferred.addCallback(handle_finish)
self.endpoint.post("v1", dummy_uaid)
Expand Down Expand Up @@ -1015,7 +1015,7 @@ def test_post_webpush_with_bad_vapid_auth(self):
def handle_finish(result):
self.endpoint.set_status.assert_called_with(401, None)
eq_(self.endpoint._client_info.get('jwt'), None)
self.assertTrue(result)
ok_(result)

self.finish_deferred.addCallback(handle_finish)
self.endpoint.post(None, dummy_uaid)
Expand Down Expand Up @@ -1049,7 +1049,7 @@ def test_post_webpush_with_bad_vapid_auth_scheme(self):
def handle_finish(result):
self.endpoint.set_status.assert_called_with(401, None)
eq_(self.endpoint._client_info.get('jwt'), None)
self.assertTrue(result)
ok_(result)

self.finish_deferred.addCallback(handle_finish)
self.endpoint.post("v2", dummy_uaid)
Expand Down Expand Up @@ -1082,7 +1082,7 @@ def test_post_webpush_no_sig(self):

def handle_finish(result):
eq_(self.endpoint._client_info.get('jwt'), None)
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(401, None)

self.finish_deferred.addCallback(handle_finish)
Expand Down Expand Up @@ -1128,7 +1128,7 @@ def test_post_webpush_bad_sig(self):

def handle_finish(result):
eq_(self.endpoint._client_info.get('jwt'), None)
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(401, None)

self.finish_deferred.addCallback(handle_finish)
Expand Down Expand Up @@ -1160,7 +1160,7 @@ def test_post_webpush_bad_exp(self):

def handle_finish(result):
eq_(self.endpoint._client_info.get('jwt'), None)
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(401, None)

self.finish_deferred.addCallback(handle_finish)
Expand All @@ -1183,7 +1183,7 @@ def test_post_webpush_with_auth(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(201)
self.endpoint.set_header.assert_called_with(
"Location", "Somewhere")
Expand All @@ -1208,7 +1208,7 @@ def test_post_webpush_with_logged_delivered(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(201)
self.endpoint.set_header.assert_called_with(
"Location", "Somewhere")
Expand All @@ -1235,7 +1235,7 @@ def test_post_webpush_with_logged_stored(self):
)

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(201)
self.endpoint.set_header.assert_called_with(
"Location", "Somewhere")
Expand Down Expand Up @@ -1311,7 +1311,7 @@ def test_put_db_error(self):
self.router_mock.get_uaid.side_effect = self._throw_provisioned_error

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(503, None)
self.finish_deferred.addCallback(handle_finish)

Expand All @@ -1323,7 +1323,7 @@ def test_put_boto_error(self):
self.router_mock.get_uaid.side_effect = self._throw_boto_err

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(503, None)
self.finish_deferred.addCallback(handle_finish)

Expand Down Expand Up @@ -1546,7 +1546,7 @@ def test_restricted_with_missing_auth(self):
self.fernet_mock.decrypt.return_value = dummy_token

def handle_finish(result):
self.assertTrue(result)
ok_(result)
self.endpoint.set_status.assert_called_with(401, None)

self.finish_deferred.addCallback(handle_finish)
Expand Down
20 changes: 10 additions & 10 deletions autopush/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,13 @@ class TestSimple(IntegrationBase):
def test_delivery_while_disconnected(self):
client = yield self.quick_register()
yield client.disconnect()
self.assertTrue(client.channels)
ok_(client.channels)
chan = client.channels.keys()[0]
yield client.send_notification(status=202)
yield client.connect()
yield client.hello()
result = yield client.get_notification()
self.assertTrue(result != {})
ok_(result != {})
self.assertTrue(len(result["updates"]) == 1)
eq_(result["updates"][0]["channelID"], chan)
yield self.shut_down(client)
Expand All @@ -466,22 +466,22 @@ def test_delivery_while_disconnected(self):
def test_delivery_repeat_without_ack(self):
client = yield self.quick_register()
yield client.disconnect()
self.assertTrue(client.channels)
ok_(client.channels)
chan = client.channels.keys()[0]
yield client.send_notification(status=202)
yield client.connect()
yield client.hello()
result = yield client.get_notification()
self.assertTrue(result != {})
ok_(result != {})
self.assertTrue(len(result["updates"]) == 1)
eq_(result["updates"][0]["channelID"], chan)

yield client.disconnect()
yield client.connect()
yield client.hello()
result = yield client.get_notification()
self.assertTrue(result != {})
self.assertTrue(result["updates"] > 0)
ok_(result != {})
ok_(result["updates"] > 0)
eq_(result["updates"][0]["channelID"], chan)
yield self.shut_down(client)

Expand All @@ -506,7 +506,7 @@ def test_direct_delivery_without_ack(self):
def test_dont_deliver_acked(self):
client = yield self.quick_register()
yield client.disconnect()
self.assertTrue(client.channels)
ok_(client.channels)
chan = client.channels.keys()[0]
yield client.send_notification(status=202)
yield client.connect()
Expand All @@ -527,7 +527,7 @@ def test_dont_deliver_acked(self):
def test_no_delivery_to_unregistered(self):
client = yield self.quick_register()
yield client.disconnect()
self.assertTrue(client.channels)
ok_(client.channels)
chan = client.channels.keys()[0]
yield client.send_notification(status=202)
yield client.connect()
Expand Down Expand Up @@ -605,7 +605,7 @@ def test_simplepush_data_delivery(self):
@inlineCallbacks
def test_webpush_data_delivery_to_connected_client(self):
client = yield self.quick_register(use_webpush=True)
self.assertTrue(client.channels)
ok_(client.channels)
chan = client.channels.keys()[0]

# Invalid UTF-8 byte sequence.
Expand Down Expand Up @@ -1084,7 +1084,7 @@ def test_empty_message_with_crypto_headers(self):
def test_delete_saved_notification(self):
client = yield self.quick_register(use_webpush=True)
yield client.disconnect()
self.assertTrue(client.channels)
ok_(client.channels)
chan = client.channels.keys()[0]
yield client.send_notification()
yield client.delete_notification(chan)
Expand Down
4 changes: 2 additions & 2 deletions autopush/tests/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ def fail():
raise twisted.internet.defer.CancelledError

def fail2(failure):
self.assertTrue(failure)
ok_(failure)

def check_result(result): # pragma: nocover
pass
Expand Down Expand Up @@ -1778,7 +1778,7 @@ def check_notifs(msg):
eq_(ver, 12)
elif uchid == chid3:
eq_(ver, 9)
self.assert_(uchid in [chid, chid3])
ok_(uchid in [chid, chid3])
d.callback(True)

def check_result(msg):
Expand Down

0 comments on commit db4e6dc

Please sign in to comment.