Пример #1
0
    def test_zip(self):
        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.zip_(
                '/tmp/salt.{{grains.id}}.zip',
                '/tmp/tmpePe8yO,/tmp/tmpLeSw1A',
                template='jinja'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'zip /tmp/salt.{{grains.id}}.zip '
                '/tmp/tmpePe8yO /tmp/tmpLeSw1A',
                template='jinja'
            )

        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.zip_(
                '/tmp/salt.{{grains.id}}.zip',
                ['/tmp/tmpePe8yO', '/tmp/tmpLeSw1A'],
                template='jinja'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'zip /tmp/salt.{{grains.id}}.zip '
                '/tmp/tmpePe8yO /tmp/tmpLeSw1A',
                template='jinja'
            )
Пример #2
0
    def test_zip(self):
        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.zip_(
                '/tmp/salt.{{grains.id}}.zip',
                '/tmp/tmpePe8yO,/tmp/tmpLeSw1A',
                template='jinja'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'zip /tmp/salt.{{grains.id}}.zip '
                '/tmp/tmpePe8yO /tmp/tmpLeSw1A',
                template='jinja'
            )

        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.zip_(
                '/tmp/salt.{{grains.id}}.zip',
                ['/tmp/tmpePe8yO', '/tmp/tmpLeSw1A'],
                template='jinja'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'zip /tmp/salt.{{grains.id}}.zip '
                '/tmp/tmpePe8yO /tmp/tmpLeSw1A',
                template='jinja'
            )
Пример #3
0
 def test_zip(self):
     ret = archive.zip_(
         '/tmp/salt.{{grains.id}}.zip',
         '/tmp/tmpePe8yO,/tmp/tmpLeSw1A',
         template='jinja'
     )
     self.assertEqual(['tmp/tmpePe8yO', 'tmp/tmpLeSw1A'], ret)
Пример #4
0
 def test_zip(self):
     ret = archive.zip_(
         '/tmp/salt.{{grains.id}}.zip',
         '/tmp/tmpePe8yO,/tmp/tmpLeSw1A',
         template='jinja'
     )
     self.assertEqual(['tmp/tmpePe8yO', 'tmp/tmpLeSw1A'], ret)
Пример #5
0
def test_zip(unicode_filename):
    """
    Validate using the zip 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)
Пример #6
0
 def test_zip(self):
     with patch('glob.glob', lambda pathname: [pathname]):
         with patch.multiple(os.path, **{'isdir': MagicMock(return_value=False),
                                         'exists': MagicMock(return_value=True)}):
             with patch('zipfile.ZipFile', MagicMock()):
                 ret = archive.zip_(
                     '/tmp/salt.{{grains.id}}.zip',
                     '/tmp/tmpePe8yO,/tmp/tmpLeSw1A',
                     template='jinja'
                 )
                 self.assertEqual(['tmp/tmpePe8yO', 'tmp/tmpLeSw1A'], ret)
Пример #7
0
def test_zip():
    with patch("glob.glob", lambda pathname: [pathname]):
        with patch.multiple(
                os.path, **{
                    "isdir": MagicMock(return_value=False),
                    "exists": MagicMock(return_value=True),
                }):
            with patch("zipfile.ZipFile", MagicMock()):
                ret = archive.zip_(
                    "/tmp/salt.{{grains.id}}.zip",
                    "/tmp/tmpePe8yO,/tmp/tmpLeSw1A",
                    template="jinja",
                )
                expected = [
                    os.path.join("tmp", "tmpePe8yO"),
                    os.path.join("tmp", "tmpLeSw1A"),
                ]
                assert expected == ret