Ejemplo n.º 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'
            )
Ejemplo n.º 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'
            )
Ejemplo n.º 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)
Ejemplo n.º 4
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)
Ejemplo n.º 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
Ejemplo n.º 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)