Tim Lauridsen wrote:
Tim Lauridsen wrote:
James Bowes wrote:
While fiddling with some test cases for package removal, I ran into some
problems with transactioninfo. It looks at the class of a package to
determine if its from the rpmdb, from a repo, or a local rpm. This makes
testing with fake packages hard.

The attached patch switches from looking at the class type to adding a
package_state variable to packages, which can be easily set for testing.
I don't think it will break any code using yum out in the wild.

Thoughts?

-James


------------------------------------------------------------------------

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Looks sane to me

Tim
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Since nobody have complained loudly :)
Can you then please commit it, it is very usefull for some of my skip-broken testcases.

Ehm, sorry. I should have spoken up on the list earlier...

I have an alternative fix for this problem. My solution has the advantage that we don't need another Package class so we can use POs more flexible in the test code while James Bowes' solution is a bit less hacky. I did not yet manage to discuss with James which solution to choose - so I put that issue on the list now.

Florian

>From e1c19c448c6095bc6adf2e090dc8870a280f8f59 Mon Sep 17 00:00:00 2001
From: Florian Festi <[EMAIL PROTECTED]>
Date: Wed, 28 Nov 2007 12:10:27 +0100
Subject: [PATCH] Packages that are to be removed can't be local packages.
 This fixes remove test cases for now - better criteria still
 needed.

---
 test/depsolvetests.py  |    7 ++-----
 yum/transactioninfo.py |   11 ++++++-----
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/test/depsolvetests.py b/test/depsolvetests.py
index 22efc44..455fb19 100644
--- a/test/depsolvetests.py
+++ b/test/depsolvetests.py
@@ -445,11 +445,8 @@ class DepsolveTests(DepsolveTests):
         updatepo = FakePackage('zip', '2', '1', '0', 'i386')
         self.xsack.addPackage(updatepo)
 
-        if new_behavior:
-            self.assertEquals('ok', *self.resolveCode())
-            self.assertResult((po, updatepo))
-        else:
-            self.assertEquals('err', *self.resolveCode())
+        self.assertEquals('ok', *self.resolveCode())
+        self.assertResult((po, updatepo))
 
     def testUpdateForConflict2(self):
         po = FakePackage('zsh', '1', '1', '0', 'i386')
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index 29954c8..8aed378 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -153,6 +153,10 @@ class TransactionData:
 
         return result
 
+    def _isLocalPackage(self, txmember):
+        # Is this the right criteria?
+        return txmember.ts_state in ('u', 'i') and not isinstance(txmember.po, (YumInstalledPackage, YumAvailablePackageSqlite))
+
     def add(self, txmember):
         """add a package to the transaction"""
         
@@ -170,9 +174,7 @@ class TransactionData:
         self.pkgdict[txmember.pkgtup].append(txmember)
         self._namedict.setdefault(txmember.name, []).append(txmember)
         self.changed = True
-
-        # Is this the right criteria?
-        if not isinstance(txmember.po, (YumInstalledPackage, YumAvailablePackageSqlite)):
+        if self._isLocalPackage(txmember):
             self.localSack.addPackage(txmember.po)
         elif isinstance(txmember.po, YumAvailablePackageSqlite):
             self.pkgSackPackages += 1
@@ -190,8 +192,7 @@ class TransactionData:
             return
         for txmbr in self.pkgdict[pkgtup]:
             txmbr.po.state = None
-            # Is this the right criteria?
-            if not isinstance(txmbr.po, (YumInstalledPackage, YumAvailablePackageSqlite)):
+            if self._isLocalPackage(txmbr):
                 self.localSack.delPackage(txmbr.po)
             elif isinstance(txmbr.po, YumAvailablePackageSqlite):
                 self.pkgSackPackages -= 1
-- 
1.5.3.3

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to