This is an automated email from the ASF dual-hosted git repository. ccy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
commit 324f0b3e3c618e724b211eca779546b61e97317a Merge: e4965ad 7ed8f70 Author: Charles Chen <charlesccyc...@users.noreply.github.com> AuthorDate: Fri Oct 5 19:11:22 2018 -0400 Merge pull request #6564 from udim/pubsub-0-35-4 [BEAM-5513] Upgrade Python SDK to PubSub 0.35.4 .../examples/complete/game/game_stats_it_test.py | 31 ++- .../examples/complete/game/leader_board_it_test.py | 32 +-- .../examples/streaming_wordcount_it_test.py | 45 ++-- sdks/python/apache_beam/io/gcp/pubsub.py | 13 +- .../apache_beam/io/gcp/pubsub_integration_test.py | 39 +-- sdks/python/apache_beam/io/gcp/pubsub_test.py | 270 ++++++--------------- .../apache_beam/io/gcp/tests/pubsub_matcher.py | 44 ++-- .../io/gcp/tests/pubsub_matcher_test.py | 75 +++--- .../apache_beam/runners/direct/direct_runner.py | 37 +-- .../runners/direct/test_direct_runner.py | 1 + .../runners/direct/transform_evaluator.py | 98 +++++--- sdks/python/apache_beam/testing/test_utils.py | 83 ++++--- sdks/python/apache_beam/testing/test_utils_test.py | 57 +---- sdks/python/container/base_image_requirements.txt | 3 +- sdks/python/setup.py | 3 +- 15 files changed, 350 insertions(+), 481 deletions(-) diff --cc sdks/python/apache_beam/testing/test_utils_test.py index bef4078,cd22df0..2b16c30 --- a/sdks/python/apache_beam/testing/test_utils_test.py +++ b/sdks/python/apache_beam/testing/test_utils_test.py @@@ -78,60 -78,23 +78,23 @@@ class TestUtilsTest(unittest.TestCase) self.assertTrue(filename.endswith('.txt')) with open(filename, 'rb') as f: - self.assertEqual(f.readline(), 'line1\n') - self.assertEqual(f.readline(), 'line2\n') - self.assertEqual(f.readline(), 'line3\n') + self.assertEqual(f.readline(), b'line1\n') + self.assertEqual(f.readline(), b'line2\n') + self.assertEqual(f.readline(), b'line3\n') - @mock.patch('time.sleep', return_value=None) - def test_wait_for_subscriptions_created_fails(self, patched_time_sleep): - sub1 = mock.MagicMock() - sub1.exists.return_value = True - sub2 = mock.MagicMock() - sub2.exists.return_value = False - with self.assertRaises(RuntimeError) as error: - utils.wait_for_subscriptions_created([sub1, sub2], timeout=0.1) - self.assertTrue(sub1.exists.called) - self.assertTrue(sub2.exists.called) - self.assertTrue(error.exception.args[0].startswith('Timeout after')) - - @mock.patch('time.sleep', return_value=None) - def test_wait_for_topics_created_fails(self, patched_time_sleep): - topic1 = mock.MagicMock() - topic1.exists.return_value = True - topic2 = mock.MagicMock() - topic2.exists.return_value = False - with self.assertRaises(RuntimeError) as error: - utils.wait_for_subscriptions_created([topic1, topic2], timeout=0.1) - self.assertTrue(topic1.exists.called) - self.assertTrue(topic2.exists.called) - self.assertTrue(error.exception.args[0].startswith('Timeout after')) - - @mock.patch('time.sleep', return_value=None) - def test_wait_for_subscriptions_created_succeeds(self, patched_time_sleep): - sub1 = mock.MagicMock() - sub1.exists.return_value = True - self.assertTrue( - utils.wait_for_subscriptions_created([sub1], timeout=0.1)) - - @mock.patch('time.sleep', return_value=None) - def test_wait_for_topics_created_succeeds(self, patched_time_sleep): - topic1 = mock.MagicMock() - topic1.exists.return_value = True - self.assertTrue( - utils.wait_for_subscriptions_created([topic1], timeout=0.1)) - self.assertTrue(topic1.exists.called) - def test_cleanup_subscriptions(self): - mock_sub = mock.MagicMock() - mock_sub.exist.return_value = True - utils.cleanup_subscriptions([mock_sub]) - self.assertTrue(mock_sub.delete.called) + sub_client = mock.Mock() + sub = mock.Mock() + sub.name = 'test_sub' + utils.cleanup_subscriptions(sub_client, [sub]) + sub_client.delete_subscription.assert_called_with(sub.name) def test_cleanup_topics(self): - mock_topics = mock.MagicMock() - mock_topics.exist.return_value = True - utils.cleanup_subscriptions([mock_topics]) - self.assertTrue(mock_topics.delete.called) + pub_client = mock.Mock() + topic = mock.Mock() + topic.name = 'test_topic' + utils.cleanup_topics(pub_client, [topic]) + pub_client.delete_topic.assert_called_with(topic.name) if __name__ == '__main__':