|
Packit |
3a9065 |
# Copyright (C) 2015 Igor Gnatenko
|
|
Packit |
3a9065 |
#
|
|
Packit |
3a9065 |
# This copyrighted material is made available to anyone wishing to use,
|
|
Packit |
3a9065 |
# modify, copy, or redistribute it subject to the terms and conditions of
|
|
Packit |
3a9065 |
# the GNU General Public License v.2, or (at your option) any later version.
|
|
Packit |
3a9065 |
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit |
3a9065 |
# ANY WARRANTY expressed or implied, including the implied warranties of
|
|
Packit |
3a9065 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
Packit |
3a9065 |
# Public License for more details. You should have received a copy of the
|
|
Packit |
3a9065 |
# GNU General Public License along with this program; if not, write to the
|
|
Packit |
3a9065 |
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit |
3a9065 |
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
|
|
Packit |
3a9065 |
# source code or documentation are not subject to the GNU General Public
|
|
Packit |
3a9065 |
# License and may only be used or replicated with the express permission of
|
|
Packit |
3a9065 |
# Red Hat, Inc.
|
|
Packit |
3a9065 |
#
|
|
Packit |
3a9065 |
|
|
Packit |
3a9065 |
from __future__ import absolute_import
|
|
Packit |
3a9065 |
from __future__ import unicode_literals
|
|
Packit |
3a9065 |
from tests.support import mock
|
|
Packit |
3a9065 |
|
|
Packit |
3a9065 |
import dnf.pycomp
|
|
Packit |
3a9065 |
import dnf.repo
|
|
Packit |
3a9065 |
import os
|
|
Packit |
3a9065 |
import repograph
|
|
Packit |
3a9065 |
import tests.support as support
|
|
Packit |
3a9065 |
|
|
Packit |
3a9065 |
|
|
Packit |
3a9065 |
class TestRepoGraphFunctions(support.TestCase):
|
|
Packit |
3a9065 |
|
|
Packit |
3a9065 |
def setUp(self):
|
|
Packit |
3a9065 |
self.cmd = repograph.RepoGraphCommand(
|
|
Packit |
3a9065 |
support.CliStub(support.BaseStub()))
|
|
Packit |
3a9065 |
self.path = os.path.join(os.path.dirname(__file__), "resources/repograph/")
|
|
Packit |
3a9065 |
|
|
Packit |
3a9065 |
def test_repoid_option(self):
|
|
Packit |
3a9065 |
args = ["--repo", "main"]
|
|
Packit |
3a9065 |
self.cmd.base.repos.add(dnf.repo.Repo(name="main"))
|
|
Packit |
3a9065 |
self.cmd.base.repos.add(dnf.repo.Repo(name="main_fail"))
|
|
Packit |
3a9065 |
support.command_configure(self.cmd, args)
|
|
Packit |
3a9065 |
repos = [repo.id for repo in self.cmd.base.repos.iter_enabled()]
|
|
Packit |
3a9065 |
self.assertEqual(["main"], repos)
|
|
Packit |
3a9065 |
|
|
Packit |
3a9065 |
def test_header(self):
|
|
Packit |
3a9065 |
args = []
|
|
Packit |
3a9065 |
with mock.patch("sys.stdout", new_callable=dnf.pycomp.StringIO) as stdout:
|
|
Packit |
3a9065 |
support.command_run(self.cmd, args)
|
|
Packit |
3a9065 |
expected_graph = ["digraph packages {", repograph.DOT_HEADER, "}\n"]
|
|
Packit |
3a9065 |
self.assertEqual(stdout.getvalue(), "\n".join(expected_graph))
|
|
Packit |
3a9065 |
|
|
Packit |
3a9065 |
def test_base(self):
|
|
Packit |
3a9065 |
args = []
|
|
Packit |
3a9065 |
self.cmd.base.add_remote_rpms([os.path.join(self.path, "noarch/foo-4-6.noarch.rpm")])
|
|
Packit |
3a9065 |
self.cmd.base.add_remote_rpms([os.path.join(self.path, "noarch/bar-4-6.noarch.rpm")])
|
|
Packit |
3a9065 |
with mock.patch("sys.stdout", new_callable=dnf.pycomp.StringIO) as stdout:
|
|
Packit |
3a9065 |
support.command_run(self.cmd, args)
|
|
Packit |
3a9065 |
expected_graph = ["digraph packages {", repograph.DOT_HEADER,
|
|
Packit |
3a9065 |
'"foo" [color="0.526086956522 0.626086956522 1.0"];',
|
|
Packit |
3a9065 |
'"foo" -> {',
|
|
Packit |
3a9065 |
'"bar"',
|
|
Packit |
3a9065 |
'} [color="0.526086956522 0.626086956522 1.0"];\n',
|
|
Packit |
3a9065 |
"}\n"]
|
|
Packit |
3a9065 |
self.assertEqual(stdout.getvalue(), "\n".join(expected_graph))
|