Example #1
0
    def test_get_chunk_info_cmdfail(self):
        class MockSSHShell2(MockSSHShell):
            def run(self, cmd):
                result = False
                stdout = ""
                return result, stdout

        scget = SplitCopyGet()
        scget.sshshell = MockSSHShell2()
        scget.scs = MockSplitCopyShared()
        scget.remote_file = "somefile.0.gz"
        with raises(SystemExit):
            scget.get_chunk_info(
                "/var/tmp/splitcopy_somefile.0.gz.220622105712")
Example #2
0
    def test_get_chunk_info_matchfail(self):
        class MockSSHShell2(MockSSHShell):
            def run(self, cmd):
                result = True
                stdout = (
                    "ls -l /var/tmp/splitcopy_somefile.0.gz.220622105712/\n"
                    "total 2K\n"
                    "-rw------- 1 foo bar    269 Jun 22 00:57 split.sh\n"
                    "foo@bar:~$")
                return result, stdout

        scget = SplitCopyGet()
        scget.sshshell = MockSSHShell2()
        scget.scs = MockSplitCopyShared()
        scget.remote_file = "somefile.0.gz"
        with raises(SystemExit):
            scget.get_chunk_info(
                "/var/tmp/splitcopy_somefile.0.gz.220622105712")
Example #3
0
    def test_get_chunk_info(self):
        class MockSSHShell2(MockSSHShell):
            def run(self, cmd):
                result = True
                stdout = (
                    "ls -l /var/tmp/splitcopy_somefile.0.gz.220622105712/\n"
                    "total 6640K\n"
                    "-rw------- 1 foo bar 677888 Jun 22 00:57 somefile.0.gz_00\n"
                    "-rw------- 1 foo bar 673790 Jun 22 00:57 somefile.0.gz_01\n"
                    "-rw------- 1 foo bar    269 Jun 22 00:57 split.sh\n"
                    "foo@bar:~$")
                return result, stdout

        scget = SplitCopyGet()
        scget.sshshell = MockSSHShell2()
        scget.remote_file = "somefile.0.gz"
        result = scget.get_chunk_info(
            "/var/tmp/splitcopy_somefile.0.gz.220622105712")
        expected = [["somefile.0.gz_00", 677888], ["somefile.0.gz_01", 673790]]
        assert expected == result