From ab475c134e219d63e6ae4265bc7237087e594aba Mon Sep 17 00:00:00 2001
From: Tim Lauridsen <timlau@fedoraproject.org>
Date: Wed, 15 Apr 2015 20:08:49 +0200
Subject: [PATCH] fix: obsolete is an install, not an update

---
 python/dnfdaemon/server/__init__.py | 16 ++++++----------
 test/test_common.py                 |  6 ++----
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/python/dnfdaemon/server/__init__.py b/python/dnfdaemon/server/__init__.py
index 7f19175..1c459de 100644
--- a/python/dnfdaemon/server/__init__.py
+++ b/python/dnfdaemon/server/__init__.py
@@ -488,7 +488,7 @@ class DnfDaemonBase(dbus.service.Object, DownloadCallback):
             elif action == 'update':
                 rc = self.base.package_upgrade(po)
             elif action == 'obsolete':
-                rc = self.base.package_upgrade(po)
+                rc = self.base.package_install(po)
             elif action == 'reinstall':
                 rc = self.base.package_reinstall(po)
             elif action == 'downgrade':
@@ -700,12 +700,12 @@ class DnfDaemonBase(dbus.service.Object, DownloadCallback):
         sublist = []
         rc, tx_list = self._make_trans_dict()
         if rc:
-            for (action, pkglist) in [('install', tx_list['install']),
+            for (action, pkglist) in [
+                ('install', tx_list['install']),
                 ('update', tx_list['update']),
                 ('remove', tx_list['remove']),
                 ('reinstall', tx_list['reinstall']),
-                ('downgrade', tx_list['downgrade']),
-                ('obsolete', tx_list['obsolete'])]:
+                ('downgrade', tx_list['downgrade'])]:
 
                 for tsi in pkglist:
                     po = _active_pkg(tsi)
@@ -729,8 +729,7 @@ class DnfDaemonBase(dbus.service.Object, DownloadCallback):
     def _make_trans_dict(self):
         """Get a dict of action & packages from the current transaction"""
         b = {}
-        for t in ('downgrade', 'remove', 'install', 'reinstall', 'update',
-                  'obsolete'):
+        for t in ('downgrade', 'remove', 'install', 'reinstall', 'update'):
             b[t] = []
         # Resolve to get the Transaction object popolated
         try:
@@ -747,10 +746,7 @@ class DnfDaemonBase(dbus.service.Object, DownloadCallback):
                 elif tsi.op_type == dnf.transaction.ERASE:
                     b['remove'].append(tsi)
                 elif tsi.op_type == dnf.transaction.INSTALL:
-                    if tsi.obsoleted:  # this is an obsolete, not an install
-                        b['obsolete'].append(tsi)
-                    else:
-                        b['install'].append(tsi)
+                    b['install'].append(tsi)
                 elif tsi.op_type == dnf.transaction.REINSTALL:
                     b['reinstall'].append(tsi)
                 elif tsi.op_type == dnf.transaction.UPGRADE:
diff --git a/test/test_common.py b/test/test_common.py
index c67d2d8..4581f9e 100644
--- a/test/test_common.py
+++ b/test/test_common.py
@@ -46,7 +46,6 @@ class TestPackages(support.TestCase):
         base = support.MockBase('main')
         pkgs = backend.Packages(base)
         inst = list(map(str, pkgs.installed))
-        print
         self.assertEqual(inst, ['bar-1.0-1.noarch',
                                 'foo-2.0-1.noarch',
                                 'bar-old-1.0-1.noarch',
@@ -67,7 +66,6 @@ class TestMultilpleUpdates(support.TestCase):
 
     def test_packages(self):
         """Test multiple updates for same pkg"""
-        print()
         base = support.MockBase('updates')
         pkgs = backend.Packages(base)
         inst = list(map(str, pkgs.installed))
@@ -354,7 +352,7 @@ class TestCommonInstall(TestCommonBase):
     def test_update_obsolete(self):
         cmds = 'bar-new'
         res = self.daemon.update(cmds)
-        expected = [True, [['obsolete', [['bar-new,0,2.0,1,noarch,main',
+        expected = [True, [['install', [['bar-new,0,2.0,1,noarch,main',
                     0.0, ['bar-old,0,1.0,1,noarch,@System',
                           'old-bar,0,1.0,1,noarch,@System']]]]]]
         self.assertEqual(json.loads(res), expected)
@@ -362,7 +360,7 @@ class TestCommonInstall(TestCommonBase):
     def test_install_obsolete(self):
         cmds = 'bar-new'
         res = self.daemon.install(cmds)
-        expected = [True, [['obsolete', [['bar-new,0,2.0,1,noarch,main',
+        expected = [True, [['install', [['bar-new,0,2.0,1,noarch,main',
                     0.0, ['bar-old,0,1.0,1,noarch,@System',
                           'old-bar,0,1.0,1,noarch,@System']]]]]]
         self.assertEqual(json.loads(res), expected)
-- 
GitLab