From db4e6dca82ad38db66d27b5221ff6dbc5e1c5d7d Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Tue, 4 Oct 2016 10:58:00 -0700 Subject: [PATCH] fix: assertTrue -> ok_ issue #674 --- autopush/tests/test_endpoint.py | 46 +++++++++++++++--------------- autopush/tests/test_integration.py | 20 ++++++------- autopush/tests/test_websocket.py | 4 +-- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/autopush/tests/test_endpoint.py b/autopush/tests/test_endpoint.py index 44735d79..a23dc93b 100644 --- a/autopush/tests/test_endpoint.py +++ b/autopush/tests/test_endpoint.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -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() @@ -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) @@ -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) @@ -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) @@ -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) @@ -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") @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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") @@ -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") @@ -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") @@ -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) @@ -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) @@ -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) diff --git a/autopush/tests/test_integration.py b/autopush/tests/test_integration.py index 2140644a..3ccdff48 100644 --- a/autopush/tests/test_integration.py +++ b/autopush/tests/test_integration.py @@ -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) @@ -466,13 +466,13 @@ 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) @@ -480,8 +480,8 @@ def test_delivery_repeat_without_ack(self): 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) @@ -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() @@ -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() @@ -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. @@ -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) diff --git a/autopush/tests/test_websocket.py b/autopush/tests/test_websocket.py index ea1e9da6..49cb13f8 100644 --- a/autopush/tests/test_websocket.py +++ b/autopush/tests/test_websocket.py @@ -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 @@ -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):