示例#1
0
 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"))
示例#2
0
    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"
                ))
示例#3
0
 def test_getfacl(self):
     hdfs_client.getfacl(
         "/tmp/test",
         executor=lambda command, *args: self.assertEqual(
             build_command(command, *args), "hadoop fs -getfacl /tmp/test"
         ),
     )
示例#4
0
 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"))
示例#5
0
 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"))
示例#6
0
 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
示例#7
0
 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"
         ),
     )
示例#8
0
 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
示例#9
0
 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"
         ),
     )
示例#10
0
 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"
         ),
     )
示例#11
0
    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"
                ),
            )
示例#12
0
文件: test_utils.py 项目: epam/Merlin
 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
示例#13
0
 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))
示例#14
0
 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))
示例#15
0
 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"),
     )
示例#16
0
 def executor(command, *args):
     self.assertEqual(build_command(command, *args), expected_command)
     return Mock(spec=Result, status=status, stdout=stdout, stderr=stderr)
示例#17
0
 def test_getfacl(self):
     hdfs_client.getfacl(
         "/tmp/test",
         executor=lambda command, *args: self.assertEqual(
             build_command(command, *args), "hadoop fs -getfacl /tmp/test"))
示例#18
0
 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
示例#19
0
 def executor(command, *args):
     self.assertEqual(build_command(command, *args), expected_command)
     return Mock(spec=Result,
                 status=status,
                 stdout=stdout,
                 stderr=stderr)
示例#20
0
 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"))