Esempio n. 1
0
    def test_has_transaction_present(self):
        """Test has_transaction with a transaction present."""
        yum_history = support.HistoryStub()
        yum_history.old_data_pkgs['1'] = (
            dnf.yum.history.YumHistoryPackageState('lotus',
                                                   'x86_64',
                                                   '0',
                                                   '3',
                                                   '16',
                                                   'Erase',
                                                   history=yum_history), )

        with self._create_wrapper(yum_history) as history:
            present = history.has_transaction(1)

        self.assertTrue(present)
Esempio n. 2
0
    def test_transaction_nevra_ops_update(self):
        """Test transaction_nevra_ops with a downgrade operation."""
        yum_history = support.HistoryStub()
        yum_history.old_data_pkgs['1'] = (
            dnf.yum.history.YumHistoryPackageState('tour',
                                                   'noarch',
                                                   '0',
                                                   '4.8',
                                                   '1',
                                                   'Update',
                                                   history=yum_history),
            dnf.yum.history.YumHistoryPackageState('tour',
                                                   'noarch',
                                                   '0',
                                                   '4.6',
                                                   '1',
                                                   'Updated',
                                                   history=yum_history),
            dnf.yum.history.YumHistoryPackageState('tour',
                                                   'noarch',
                                                   '0',
                                                   '4.8',
                                                   '1',
                                                   'Obsoleting',
                                                   history=yum_history),
            dnf.yum.history.YumHistoryPackageState('lotus',
                                                   'x86_64',
                                                   '0',
                                                   '3',
                                                   '16',
                                                   'Obsoleted',
                                                   history=yum_history))
        expected_ops = dnf.history.NEVRAOperations()
        expected_ops.add('Update', 'tour-0:4.8-1.noarch',
                         'tour-0:4.6-1.noarch', ('lotus-0:3-16.x86_64', ))

        with self._create_wrapper(yum_history) as history:
            result_ops = history.transaction_nevra_ops(1)

        self.assertCountEqual(result_ops, expected_ops)
Esempio n. 3
0
    def test_last_transaction_id(self):
        """Test last_transaction_id with some transactions."""
        yum_history = support.HistoryStub()
        yum_history.old_data_pkgs['1'] = (
            dnf.yum.history.YumHistoryPackageState('lotus',
                                                   'x86_64',
                                                   '0',
                                                   '3',
                                                   '16',
                                                   'Erase',
                                                   history=yum_history), )
        yum_history.old_data_pkgs['2'] = (
            dnf.yum.history.YumHistoryPackageState('pepper',
                                                   'x86_64',
                                                   '0',
                                                   '20',
                                                   '0',
                                                   'Install',
                                                   history=yum_history), )

        with self._create_wrapper(yum_history) as history:
            id_ = history.last_transaction_id()

        self.assertEqual(id_, 2)
Esempio n. 4
0
    def test_has_transaction_absent(self):
        """Test has_transaction without any transaction."""
        with self._create_wrapper(support.HistoryStub()) as history:
            present = history.has_transaction(1)

        self.assertFalse(present)
Esempio n. 5
0
 def test_transaction_nevra_ops_notransaction(self):
     """Test transaction_nevra_ops without any transaction."""
     with self._create_wrapper(support.HistoryStub()) as history:
         self.assertRaises(ValueError, history.transaction_nevra_ops, 0)
Esempio n. 6
0
    def test_last_transaction_id_notransaction(self):
        """Test last_transaction_id without any transaction."""
        with self._create_wrapper(support.HistoryStub()) as history:
            id_ = history.last_transaction_id()

        self.assertIsNone(id_)