Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2 from yyu/fix
Browse files Browse the repository at this point in the history
no assert_called() for older versions of mock
  • Loading branch information
yyu committed Dec 4, 2018
2 parents 80a1b40 + 4acef7c commit a20869e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ This node will require the following AWS account IAM role permissions:

#### Build from Source

If you test this package on versions of Ubuntu older than 18.x (16.04 for example), please upgrade `mock` to the latest version by using `pip`.

sudo apt-get python-pip
pip install -U mock requests

Create a ROS workspace and a source directory

mkdir -p ~/ros-workspace/src
Expand Down
1 change: 1 addition & 0 deletions tts/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@

<test_depend>rosunit</test_depend>
<test_depend>rostest</test_depend>
<test_depend>python-mock</test_depend>
</package>
10 changes: 5 additions & 5 deletions tts/test/test_unit_polly.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ def test_init(self, boto3_session_class_mock):
from tts.amazonpolly import AmazonPolly
AmazonPolly()

boto3_session_class_mock.assert_called()
self.assertGreater(boto3_session_class_mock.call_count, 0)
boto3_session_class_mock.return_value.client.assert_called_with('polly')

@patch('tts.amazonpolly.Session')
def test_defaults(self, boto3_session_class_mock):
from tts.amazonpolly import AmazonPolly
polly = AmazonPolly()

boto3_session_class_mock.assert_called()
self.assertGreater(boto3_session_class_mock.call_count, 0)
boto3_session_class_mock.return_value.client.assert_called_with('polly')

self.assertEqual('text', polly.default_text_type)
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_good_synthesis_with_default_args(self, boto3_session_class_mock):
from tts.amazonpolly import AmazonPolly
polly_under_test = AmazonPolly()

boto3_session_class_mock.assert_called()
self.assertGreater(boto3_session_class_mock.call_count, 0)
boto3_session_obj_mock.client.assert_called_with('polly')

res = polly_under_test.synthesize(text='hello')
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_polly_raises(self, boto3_session_class_mock):
from tts.amazonpolly import AmazonPolly
polly_under_test = AmazonPolly()

boto3_session_class_mock.assert_called()
self.assertGreater(boto3_session_class_mock.call_count, 0)
boto3_session_obj_mock.client.assert_called_with('polly')

res = polly_under_test.synthesize(text='hello')
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_cli(self, amazon_polly_class_mock):
with patch.object(sys, 'argv', ['polly_node.py', '-n', 'polly-node']):
from tts import amazonpolly
amazonpolly.main()
amazon_polly_class_mock.assert_called()
self.assertGreater(amazon_polly_class_mock.call_count, 0)
amazon_polly_class_mock.return_value.start.assert_called_with(node_name='polly-node', service_name='polly')


Expand Down
6 changes: 3 additions & 3 deletions tts/test/test_unit_synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_good_synthesis_with_mostly_default_args_using_polly_lib(self, polly_cla
request = SynthesizerRequest(text=test_text, metadata=test_metadata)
response = speech_synthesizer._node_request_handler(request)

polly_class_mock.assert_called()
self.assertGreater(polly_class_mock.call_count, 0)
polly_obj_mock.synthesize.assert_called_with(**expected_polly_synthesize_args)

self.assertEqual(response.result, polly_obj_mock.synthesize.return_value.result)
Expand Down Expand Up @@ -131,7 +131,7 @@ def test_cli_engine_dispatching_2(self, speech_synthesizer_class_mock):
from tts import synthesizer
synthesizer.main()
speech_synthesizer_class_mock.assert_called_with(engine='POLLY_LIBRARY')
speech_synthesizer_class_mock.return_value.start.assert_called()
self.assertGreater(speech_synthesizer_class_mock.return_value.start.call_count, 0)

@patch('tts.synthesizer.SpeechSynthesizer')
def test_cli_engine_dispatching_3(self, speech_synthesizer_class_mock):
Expand All @@ -140,7 +140,7 @@ def test_cli_engine_dispatching_3(self, speech_synthesizer_class_mock):
from tts import synthesizer
synthesizer.main()
speech_synthesizer_class_mock.assert_called_with(engine='POLLY_SERVICE', polly_service_name='apolly')
speech_synthesizer_class_mock.return_value.start.assert_called()
self.assertGreater(speech_synthesizer_class_mock.return_value.start.call_count, 0)


if __name__ == '__main__':
Expand Down

0 comments on commit a20869e

Please sign in to comment.