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' )
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)
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)
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)
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