Merge "add unit test for test_hdfs_helper"

This commit is contained in:
Jenkins 2015-08-10 21:19:07 +00:00 committed by Gerrit Code Review
commit b52f392135

View File

@ -132,3 +132,14 @@ class HDFSHelperTestCase(base.SaharaTestCase):
mock.call().__enter__().write_file_to(str1, mock_helper()),
mock.call().__enter__().execute_command(str2, run_as_root=True),
mock.call().__exit__(None, None, None)])
@mock.patch('six.text_type')
@mock.patch('os.open')
def test_put_file_to_hdfs(self, open_get, mock_six):
open_get.return_value = '/tmp/workflow.xml'
mock_six.return_value = 111
helper.put_file_to_hdfs(self.cluster, open_get, 'workflow',
'/tmp', 'hdfs')
self.cluster.execute_command.assert_called_once_with(
'sudo su - -c "hadoop dfs -copyFromLocal /tmp/workflow.111'
' /tmp/workflow" hdfs && sudo rm -f /tmp/workflow.111')