|
Packit Service |
27f74b |
# Copyright (C) 2014 Red Hat, Inc.
|
|
Packit Service |
27f74b |
#
|
|
Packit Service |
27f74b |
# This copyrighted material is made available to anyone wishing to use,
|
|
Packit Service |
27f74b |
# modify, copy, or redistribute it subject to the terms and conditions of
|
|
Packit Service |
27f74b |
# the GNU General Public License v.2, or (at your option) any later version.
|
|
Packit Service |
27f74b |
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit Service |
27f74b |
# ANY WARRANTY expressed or implied, including the implied warranties of
|
|
Packit Service |
27f74b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
Packit Service |
27f74b |
# Public License for more details. You should have received a copy of the
|
|
Packit Service |
27f74b |
# GNU General Public License along with this program; if not, write to the
|
|
Packit Service |
27f74b |
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
27f74b |
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
|
|
Packit Service |
27f74b |
# source code or documentation are not subject to the GNU General Public
|
|
Packit Service |
27f74b |
# License and may only be used or replicated with the express permission of
|
|
Packit Service |
27f74b |
# Red Hat, Inc.
|
|
Packit Service |
27f74b |
#
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
from __future__ import absolute_import
|
|
Packit Service |
27f74b |
from __future__ import unicode_literals
|
|
Packit Service |
27f74b |
from tests import support
|
|
Packit Service |
27f74b |
import dnf.exceptions
|
|
Packit Service |
27f74b |
import reposync
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
import dnf.repo
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
class TestReposyncFunctions(support.TestCase):
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
def setUp(self):
|
|
Packit Service |
27f74b |
cli = support.CliStub(support.BaseCliStub())
|
|
Packit Service |
27f74b |
self.cmd = reposync.RepoSyncCommand(cli)
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
def test_parse_args(self):
|
|
Packit Service |
27f74b |
args = '-p /become/legend --repo=silver --repo=screen'.split()
|
|
Packit Service |
27f74b |
self.cmd.base.repos.add(dnf.repo.Repo('silver'))
|
|
Packit Service |
27f74b |
self.cmd.base.repos.add(dnf.repo.Repo('screen'))
|
|
Packit Service |
27f74b |
support.command_configure(self.cmd, args)
|
|
Packit Service |
27f74b |
self.assertEqual(self.cmd.opts.repo, ['silver', 'screen'])
|
|
Packit Service |
27f74b |
self.assertEqual(self.cmd.opts.download_path, '/become/legend')
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
def test_pkgdir(self):
|
|
Packit Service |
27f74b |
self.assertEqual(reposync._pkgdir('/honey/../pie', 'crazy'),
|
|
Packit Service |
27f74b |
'/pie/crazy')
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
def test_pkg_download_path(self):
|
|
Packit Service |
27f74b |
args = '-p /become/legend'.split()
|
|
Packit Service |
27f74b |
repo = support.RepoStub('silver')
|
|
Packit Service |
27f74b |
support.command_configure(self.cmd, args)
|
|
Packit Service |
27f74b |
pkg = support.PkgStub('foo', '0', '1.0', '1', 'noarch', 'silver',
|
|
Packit Service |
27f74b |
repo=repo, location="foo-0-1.0-1.noarch.rpm")
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
pkgpath = self.cmd.pkg_download_path(pkg)
|
|
Packit Service |
27f74b |
self.assertEqual(pkgpath, '/become/legend/silver/foo-0-1.0-1.noarch.rpm')
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
pkg.location = "../pool/foo-0-1.0-1.noarch.rpm"
|
|
Packit Service |
27f74b |
with self.assertRaises(dnf.exceptions.Error):
|
|
Packit Service |
27f74b |
self.cmd.pkg_download_path(pkg)
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
def test_metadata_target_default(self):
|
|
Packit Service |
27f74b |
args = '-p /become/legend'.split()
|
|
Packit Service |
27f74b |
repo = support.RepoStub('silver')
|
|
Packit Service |
27f74b |
support.command_configure(self.cmd, args)
|
|
Packit Service |
27f74b |
metadata_path = self.cmd.metadata_target(repo)
|
|
Packit Service |
27f74b |
self.assertEqual(metadata_path, '/become/legend/silver')
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
def test_metadata_target_given(self):
|
|
Packit Service |
27f74b |
args = '-p /become/legend --metadata-path=/the/president'.split()
|
|
Packit Service |
27f74b |
repo = support.RepoStub('silver')
|
|
Packit Service |
27f74b |
support.command_configure(self.cmd, args)
|
|
Packit Service |
27f74b |
metadata_path = self.cmd.metadata_target(repo)
|
|
Packit Service |
27f74b |
self.assertEqual(metadata_path, '/the/president/silver')
|