Added unit tests for 'Unicode support shell client'

Added unit tests for https://review.openstack.org/#/c/206037/

Change-Id: I78369fadeb8fee6434a4d5d9ded7e9e877043487
Closes-bug: #1499390
This commit is contained in:
Darja Shakhray
2015-09-25 16:02:44 +03:00
parent 22868aa9bb
commit abf0381e36

View File

@@ -301,6 +301,26 @@ class ShellV2Test(testtools.TestCase):
except Exception:
pass
@mock.patch('sys.stdin', autospec=True)
def test_do_image_create_with_unicode(self, mock_stdin):
name = u'\u041f\u0420\u0418\u0412\u0415\u0422\u0418\u041a'
args = self._make_args({'name': name,
'file': None})
with mock.patch.object(self.gc.images, 'create') as mocked_create:
ignore_fields = ['self', 'access', 'file', 'schema']
expect_image = dict((field, field) for field in ignore_fields)
expect_image['id'] = 'pass'
expect_image['name'] = name
mocked_create.return_value = expect_image
mock_stdin.isatty = lambda: True
test_shell.do_image_create(self.gc, args)
mocked_create.assert_called_once_with(name=name)
utils.print_dict.assert_called_once_with({
'id': 'pass', 'name': name})
@mock.patch('sys.stdin', autospec=True)
def test_do_image_create_with_user_props(self, mock_stdin):
args = self._make_args({'name': 'IMG-01',