From e9fd8a1c1ea9ac7e50af08136c7f352fed90aea4 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Tue, 4 Oct 2016 10:53:35 -0700 Subject: [PATCH] fix: adapt asserts to ok/eq_ issue #674 --- autopush/tests/test_db.py | 16 ++++++++-------- autopush/tests/test_diagnostic_cli.py | 3 ++- autopush/tests/test_main.py | 6 ++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/autopush/tests/test_db.py b/autopush/tests/test_db.py index 1bcfdcfc..85743f9b 100644 --- a/autopush/tests/test_db.py +++ b/autopush/tests/test_db.py @@ -151,8 +151,8 @@ def test_provisioning(self): db_name = "storage_%s" % uuid.uuid4() s = create_storage_table(db_name, 8, 11) - assert s.throughput["read"] == 8 - assert s.throughput["write"] == 11 + eq_(s.throughput["read"], 8) + eq_(s.throughput["write"], 11) def test_dont_save_older(self): s = get_storage_table() @@ -236,7 +236,7 @@ def test_register(self): # Verify its in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) - assert(len(results) == 1) + eq_(len(results), 1) def test_unregister(self): chid = str(uuid.uuid4()) @@ -247,7 +247,7 @@ def test_unregister(self): # Verify its in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) - assert(len(results) == 1) + eq_(len(results), 1) eq_(results[0]["chids"], set([chid])) message.unregister_channel(self.uaid, chid) @@ -255,7 +255,7 @@ def test_unregister(self): # Verify its not in the db rows = m.query_2(uaid__eq=self.uaid, chidmessageid__eq=" ") results = list(rows) - assert(len(results) == 1) + eq_(len(results), 1) eq_(results[0]["chids"], None) # Test for the very unlikely case that there's no 'chid' @@ -301,7 +301,7 @@ def test_all_channels_no_uaid(self): m = get_rotating_message_table() message = Message(m, SinkMetrics()) exists, chans = message.all_channels(dummy_uaid) - assert(chans == set([])) + eq_(chans, set([])) def test_message_storage(self): chid = str(uuid.uuid4()) @@ -396,8 +396,8 @@ def test_provisioning(self): db_name = "router_%s" % uuid.uuid4() r = create_router_table(db_name, 3, 17) - assert r.throughput["read"] == 3 - assert r.throughput["write"] == 17 + eq_(r.throughput["read"], 3) + eq_(r.throughput["write"], 17) def test_no_uaid_found(self): uaid = str(uuid.uuid4()) diff --git a/autopush/tests/test_diagnostic_cli.py b/autopush/tests/test_diagnostic_cli.py index c20c2753..91bad1da 100644 --- a/autopush/tests/test_diagnostic_cli.py +++ b/autopush/tests/test_diagnostic_cli.py @@ -37,7 +37,8 @@ def test_bad_endpoint(self): "--router_tablename=fred", "http://someendpoint", ]) - assert cli.run() + returncode = cli.run() + ok_(returncode not in (None, 0)) @patch("autopush.diagnostic_cli.AutopushSettings") def test_successfull_lookup(self, mock_settings_class): diff --git a/autopush/tests/test_main.py b/autopush/tests/test_main.py index 98d3314a..51592b4b 100644 --- a/autopush/tests/test_main.py +++ b/autopush/tests/test_main.py @@ -280,15 +280,17 @@ def test_ssl(self): ], False) def test_bad_senderidlist(self): - assert endpoint_main([ + returncode = endpoint_main([ "--gcm_enabled", "--senderid_list='[Invalid'" ], False) + ok_(returncode not in (None, 0)) def test_bad_apnsconf(self): - assert endpoint_main([ + returncode = endpoint_main([ "--apns_creds='[Invalid'" ], False) + ok_(returncode not in (None, 0)) def test_client_certs(self): cert = self.TestArg._client_certs['partner1'][0]