def test_copy_from_local_command_generator(self): hdfs_client.copy_from_local( localsrc="~/data.txt", hdfsdst="/tmp/dir", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -copyFromLocal ~/data.txt /tmp/dir"))
def test_copy_command_generator(self): hdfs_client.copy(files="/tmp/data.txt", dest="/raw/dir", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -cp /tmp/data.txt /raw/dir")) with patch(HDFS_IS_DIR_FUNC) as mock_isdir: mock_isdir.return_value = True hdfs_client.copy( files=["/tmp/file_001.txt", "/tmp/file_002.txt"], dest="/raw/dir", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -cp /tmp/file_001.txt /tmp/file_002.txt /raw/dir" ))
def test_getfacl(self): hdfs_client.getfacl( "/tmp/test", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -getfacl /tmp/test" ), )
def test_setfacl(self): hdfs_client.setfacl( "/tmp/test", "user:hadoop:rw-", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -setfacl -m user:hadoop:rw- /tmp/test"))
def test_copy_to_local_command_generator(self): hdfs_client.copy_to_local( path="/tmp/test", localdst="~/dir", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -copyToLocal /tmp/test ~/dir"))
def executor(cmd, *args): self.assertEqual(expected_command, build_command(cmd, *args)) result = mock.Mock(spec=Result, status=status, stdout=stdout, stderr=stderr) return result
def test_setfacl(self): hdfs_client.setfacl( "/tmp/test", "user:hadoop:rw-", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -setfacl -m user:hadoop:rw- /tmp/test" ), )
def executor(cmd, *args): _actual_cmd = build_command(cmd, *args) if expected_command != _actual_cmd: raise AssertionError( "ERROR: expected and actual command are different: \n\tEXPECTED: " "{0}\n\tACTUAL: {1}".format(expected_command, _actual_cmd)) result = Mock(spec=Result, status=status, stdout=stdout, stderr=stderr) return result
def test_copy_to_local_command_generator(self): hdfs_client.copy_to_local( path="/tmp/test", localdst="~/dir", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -copyToLocal /tmp/test ~/dir" ), )
def test_copy_from_local_command_generator(self): hdfs_client.copy_from_local( localsrc="~/data.txt", hdfsdst="/tmp/dir", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -copyFromLocal ~/data.txt /tmp/dir" ), )
def test_copy_command_generator(self): hdfs_client.copy( files="/tmp/data.txt", dest="/raw/dir", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -cp /tmp/data.txt /raw/dir" ), ) with patch(HDFS_IS_DIR_FUNC) as mock_isdir: mock_isdir.return_value = True hdfs_client.copy( files=["/tmp/file_001.txt", "/tmp/file_002.txt"], dest="/raw/dir", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -cp /tmp/file_001.txt /tmp/file_002.txt /raw/dir" ), )
def executor(cmd, *args): _actual_cmd = build_command(cmd, *args) if expected_command != _actual_cmd: raise AssertionError( "ERROR: expected and actual command are different: \n\tEXPECTED: " "{0}\n\tACTUAL: {1}".format( expected_command, _actual_cmd)) result = Mock(spec=Result, status=status, stdout=stdout, stderr=stderr) return result
def executor(cmd, *args): actual_command = build_command(cmd, *args) self.assertEqual(expected_cmd, actual_command, "\n\nEXPECTED : %s \nACTUAL : %s" % (expected_cmd, actual_command))
def executor(cmd, *args): actual_command = build_command(cmd, *args) self.assertEqual( expected_cmd, actual_command, "\n\nEXPECTED : %s \nACTUAL : %s" % (expected_cmd, actual_command))
def test_mkdir_command_generator_negative(self): hdfs_client.mkdir( "/tmp/test", executor=lambda command, *args: self.assertEqual(build_command(command, *args), "mkdir /tmp/test"), )
def executor(command, *args): self.assertEqual(build_command(command, *args), expected_command) return Mock(spec=Result, status=status, stdout=stdout, stderr=stderr)
def test_getfacl(self): hdfs_client.getfacl( "/tmp/test", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "hadoop fs -getfacl /tmp/test"))
def test_mkdir_command_generator_negative(self): hdfs_client.mkdir( "/tmp/test", executor=lambda command, *args: self.assertEqual( build_command(command, *args), "mkdir /tmp/test"))