diff --git a/test/dnf5daemon-server/support.py b/test/dnf5daemon-server/support.py index 6a6b2b1d66..f741a83dc1 100644 --- a/test/dnf5daemon-server/support.py +++ b/test/dnf5daemon-server/support.py @@ -36,6 +36,19 @@ class InstallrootCase(unittest.TestCase): + def sanitize_transaction(self, resolved): + '''Prepare resolved transaction for assert''' + for object_type, action, reason, trans_item_attrs, pkg in resolved: + # id of package depends on order of the repos in the sack which varies + # between runs so we can't rely on the value + pkg.pop('id') + # also package size differs according to the builder + pkg.pop('package_size') + # TODO(mblaha): calculate correct replaces value + if "replaces" in trans_item_attrs: + trans_item_attrs.pop("replaces") + + def setUp(self): super(InstallrootCase, self).setUp() self.maxDiff = None diff --git a/test/dnf5daemon-server/test_distro_sync.py b/test/dnf5daemon-server/test_distro_sync.py index d276552d7e..1d319f1b07 100644 --- a/test/dnf5daemon-server/test_distro_sync.py +++ b/test/dnf5daemon-server/test_distro_sync.py @@ -35,19 +35,18 @@ def test_distro_sync_package(self): self.iface_rpm.distro_sync(['one'], dbus.Dictionary({}, signature='sv')) resolved, errors = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv')) - - # id of package depends on order of the repos in the sack which varies - # between runs so we can't rely on the value - for action, pkg in resolved: - pkg.pop('id') - pkg.pop('package_size') + self.sanitize_transaction(resolved) self.assertCountEqual( resolved, dbus.Array([ dbus.Struct(( - dbus.UInt32(6), # action upgrade - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Upgrade'), # action + dbus.String('External User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('evr'): dbus.String('2-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), @@ -55,12 +54,18 @@ def test_distro_sync_package(self): dbus.String('release'): dbus.String('1', variant_level=1), dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), - dbus.String('repo'): dbus.String('rpm-repo1', variant_level=1), + dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('External User', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None), dbus.Struct(( - dbus.UInt32(12), # action replaced - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Replaced'), # action + dbus.String('External User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('evr'): dbus.String('1-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), @@ -68,7 +73,9 @@ def test_distro_sync_package(self): dbus.String('release'): dbus.String('1', variant_level=1), dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), - dbus.String('repo'): dbus.String('@System', variant_level=1), + dbus.String('repo_id'): dbus.String('@System', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('External User', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None) ], signature=dbus.Signature('(ua{sv})')) diff --git a/test/dnf5daemon-server/test_downgrade.py b/test/dnf5daemon-server/test_downgrade.py index 3663332b7b..b9a14028cd 100644 --- a/test/dnf5daemon-server/test_downgrade.py +++ b/test/dnf5daemon-server/test_downgrade.py @@ -35,20 +35,19 @@ def test_downgrade_package(self): self.iface_rpm.downgrade(['one'], dbus.Dictionary({}, signature='sv')) resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv')) - - # id of package depends on order of the repos in the sack which varies - # between runs so we can't rely on the value - for action, pkg in resolved: - pkg.pop('id') - pkg.pop('package_size') + self.sanitize_transaction(resolved) self.assertEqual(result, 0) self.assertCountEqual( resolved, dbus.Array([ dbus.Struct(( - dbus.UInt32(2), # action downgrade - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Downgrade'), # action + dbus.String('External User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('evr'): dbus.String('1-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), @@ -56,12 +55,18 @@ def test_downgrade_package(self): dbus.String('release'): dbus.String('1', variant_level=1), dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), - dbus.String('repo'): dbus.String('rpm-repo1', variant_level=1), + dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('External User', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None), dbus.Struct(( - dbus.UInt32(12), # action replaced - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Replaced'), # action + dbus.String('External User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('evr'): dbus.String('2-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), @@ -69,7 +74,9 @@ def test_downgrade_package(self): dbus.String('release'): dbus.String('1', variant_level=1), dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), - dbus.String('repo'): dbus.String('@System', variant_level=1), + dbus.String('repo_id'): dbus.String('@System', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('External User', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None) ], signature=dbus.Signature('(ua{sv})')) diff --git a/test/dnf5daemon-server/test_install.py b/test/dnf5daemon-server/test_install.py index 90e233a060..e041b8d883 100644 --- a/test/dnf5daemon-server/test_install.py +++ b/test/dnf5daemon-server/test_install.py @@ -26,28 +26,29 @@ def test_install_package(self): self.iface_rpm.install(['one'], dbus.Dictionary({}, signature='sv')) resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv')) - - # id of package depends on order of the repos in the sack which varies - # between runs so we can't rely on the value - for action, pkg in resolved: - pkg.pop('id') - pkg.pop('package_size') + self.sanitize_transaction(resolved) self.assertEqual(result, 0) self.assertCountEqual( resolved, dbus.Array([ dbus.Struct(( - dbus.UInt32(1), # action - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Install'), # action + dbus.String('User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), dbus.String('evr'): dbus.String('2-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), dbus.String('release'): dbus.String('1', variant_level=1), - dbus.String('repo'): dbus.String('rpm-repo1', variant_level=1), - dbus.String('version'): dbus.String('2', variant_level=1) + dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1), + dbus.String('version'): dbus.String('2', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('None', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None) ], signature=dbus.Signature('(ua{sv})')) diff --git a/test/dnf5daemon-server/test_reinstall.py b/test/dnf5daemon-server/test_reinstall.py index 5e9ea63164..54af691aca 100644 --- a/test/dnf5daemon-server/test_reinstall.py +++ b/test/dnf5daemon-server/test_reinstall.py @@ -35,20 +35,19 @@ def test_reinstall_package(self): self.iface_rpm.reinstall(['one'], dbus.Dictionary({}, signature='sv')) resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv')) - - # id of package depends on order of the repos in the sack which varies - # between runs so we can't rely on the value - for action, pkg in resolved: - pkg.pop('id') - pkg.pop('package_size') + self.sanitize_transaction(resolved) self.assertEqual(result, 0) self.assertCountEqual( resolved, dbus.Array([ dbus.Struct(( - dbus.UInt32(9), # action reinstall - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Reinstall'), # action + dbus.String('External User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('evr'): dbus.String('1-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), @@ -56,12 +55,18 @@ def test_reinstall_package(self): dbus.String('release'): dbus.String('1', variant_level=1), dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), - dbus.String('repo'): dbus.String('rpm-repo1', variant_level=1), + dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('External User', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None), dbus.Struct(( - dbus.UInt32(12), # action replaced - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Replaced'), # action + dbus.String('External User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('evr'): dbus.String('1-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), @@ -69,7 +74,9 @@ def test_reinstall_package(self): dbus.String('release'): dbus.String('1', variant_level=1), dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), - dbus.String('repo'): dbus.String('@System', variant_level=1), + dbus.String('repo_id'): dbus.String('@System', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('External User', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None) ], signature=dbus.Signature('(ua{sv})')), diff --git a/test/dnf5daemon-server/test_remove.py b/test/dnf5daemon-server/test_remove.py index e94248a02a..47e6c3fca2 100644 --- a/test/dnf5daemon-server/test_remove.py +++ b/test/dnf5daemon-server/test_remove.py @@ -35,28 +35,29 @@ def test_remove_package(self): self.iface_rpm.remove(['one'], dbus.Dictionary({}, signature='sv')) resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv')) - - # id of package depends on order of the repos in the sack which varies - # between runs so we can't rely on the value - for action, pkg in resolved: - pkg.pop('id') - pkg.pop('package_size') + self.sanitize_transaction(resolved) self.assertEqual(result, 0) self.assertCountEqual( resolved, dbus.Array([ dbus.Struct(( - dbus.UInt32(8), # action - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Remove'), # action + dbus.String('User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), dbus.String('evr'): dbus.String('1-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), dbus.String('release'): dbus.String('1', variant_level=1), - dbus.String('repo'): dbus.String('@System', variant_level=1), - dbus.String('version'): dbus.String('1', variant_level=1) + dbus.String('repo_id'): dbus.String('@System', variant_level=1), + dbus.String('version'): dbus.String('1', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('External User', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None) ], signature=dbus.Signature('(ua{sv})')) diff --git a/test/dnf5daemon-server/test_upgrade.py b/test/dnf5daemon-server/test_upgrade.py index 785bba6b6f..dc60bb227a 100644 --- a/test/dnf5daemon-server/test_upgrade.py +++ b/test/dnf5daemon-server/test_upgrade.py @@ -35,20 +35,19 @@ def test_upgrade_package(self): self.iface_rpm.upgrade(['one'], dbus.Dictionary({}, signature='sv')) resolved, result = self.iface_goal.resolve(dbus.Dictionary({}, signature='sv')) - - # id of package depends on order of the repos in the sack which varies - # between runs so we can't rely on the value - for action, pkg in resolved: - pkg.pop('id') - pkg.pop('package_size') + self.sanitize_transaction(resolved) self.assertEqual(result, 0) self.assertCountEqual( resolved, dbus.Array([ dbus.Struct(( - dbus.UInt32(6), # action upgrade - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Upgrade'), # action + dbus.String('External User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('evr'): dbus.String('2-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), @@ -56,12 +55,18 @@ def test_upgrade_package(self): dbus.String('release'): dbus.String('1', variant_level=1), dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), - dbus.String('repo'): dbus.String('rpm-repo1', variant_level=1), + dbus.String('repo_id'): dbus.String('rpm-repo1', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('External User', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None), dbus.Struct(( - dbus.UInt32(12), # action replaced - dbus.Dictionary({ # package + dbus.String('Package'), # object type + dbus.String('Replaced'), # action + dbus.String('External User'), # reason + dbus.Dictionary({ # transaction item attrs + }, signature=dbus.Signature('sv')), + dbus.Dictionary({ # package dbus.String('evr'): dbus.String('1-1', variant_level=1), dbus.String('name'): dbus.String('one', variant_level=1), dbus.String('epoch'): dbus.String('0', variant_level=1), @@ -69,7 +74,9 @@ def test_upgrade_package(self): dbus.String('release'): dbus.String('1', variant_level=1), dbus.String('arch'): dbus.String('noarch', variant_level=1), dbus.String('install_size'): dbus.UInt64(0, variant_level=1), - dbus.String('repo'): dbus.String('@System', variant_level=1), + dbus.String('repo_id'): dbus.String('@System', variant_level=1), + dbus.String('from_repo_id'): dbus.String('', variant_level=1), + dbus.String('reason'): dbus.String('External User', variant_level=1), }, signature=dbus.Signature('sv'))), signature=None) ], signature=dbus.Signature('(ua{sv})'))