예제 #1
0
    def test_unzip(self):
        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.unzip(
                '/tmp/salt.{{grains.id}}.zip',
                '/tmp/dest',
                excludes='/tmp/tmpePe8yO,/tmp/tmpLeSw1A',
                template='jinja'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'unzip /tmp/salt.{{grains.id}}.zip -d /tmp/dest '
                '-x /tmp/tmpePe8yO /tmp/tmpLeSw1A',
                template='jinja'
            )

        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.unzip(
                '/tmp/salt.{{grains.id}}.zip',
                '/tmp/dest',
                excludes=['/tmp/tmpePe8yO', '/tmp/tmpLeSw1A'],
                template='jinja'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'unzip /tmp/salt.{{grains.id}}.zip -d /tmp/dest '
                '-x /tmp/tmpePe8yO /tmp/tmpLeSw1A',
                template='jinja'
            )
예제 #2
0
    def test_unzip(self):
        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.unzip(
                '/tmp/salt.{{grains.id}}.zip',
                '/tmp/dest',
                excludes='/tmp/tmpePe8yO,/tmp/tmpLeSw1A',
                template='jinja'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'unzip /tmp/salt.{{grains.id}}.zip -d /tmp/dest '
                '-x /tmp/tmpePe8yO /tmp/tmpLeSw1A',
                template='jinja'
            )

        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.unzip(
                '/tmp/salt.{{grains.id}}.zip',
                '/tmp/dest',
                excludes=['/tmp/tmpePe8yO', '/tmp/tmpLeSw1A'],
                template='jinja'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'unzip /tmp/salt.{{grains.id}}.zip -d /tmp/dest '
                '-x /tmp/tmpePe8yO /tmp/tmpLeSw1A',
                template='jinja'
            )
예제 #3
0
 def test_unzip(self):
     mock = ZipFileMock()
     with patch('zipfile.ZipFile', mock):
         ret = archive.unzip('/tmp/salt.{{grains.id}}.zip',
                             '/tmp/dest',
                             excludes='/tmp/tmpePe8yO,/tmp/tmpLeSw1A',
                             template='jinja')
         self.assertEqual(['salt'], ret)
예제 #4
0
파일: archive_test.py 프로젝트: DaveQB/salt
 def test_unzip(self):
     mock = ZipFileMock()
     with patch('zipfile.ZipFile', mock):
         ret = archive.unzip(
             '/tmp/salt.{{grains.id}}.zip',
             '/tmp/dest',
             excludes='/tmp/tmpePe8yO,/tmp/tmpLeSw1A',
             template='jinja'
         )
         self.assertEqual(['salt'], ret)
예제 #5
0
def test_unzip():
    mock = ZipFileMock()
    with patch("zipfile.ZipFile", mock):
        ret = archive.unzip(
            "/tmp/salt.{{grains.id}}.zip",
            "/tmp/dest",
            excludes="/tmp/tmpePe8yO,/tmp/tmpLeSw1A",
            template="jinja",
            extract_perms=False,
        )
        assert ["salt"] == ret
예제 #6
0
def test_unzip(unicode_filename):
    """
    Validate using the unzip function
    """
    with Archive("zip", unicode_filename=unicode_filename) as arch:
        ret = archive.zip_(str(arch.archive), str(arch.src))
        assert isinstance(ret, list)
        arch.assert_artifacts_in_ret(ret)

        ret = archive.unzip(str(arch.archive), str(arch.dst))
        assert isinstance(ret, list)
        arch.assert_artifacts_in_ret(ret, unix_sep=False)