aboutsummaryrefslogtreecommitdiff
path: root/tests/test_trans_chain.py
blob: 209d7d710da10dc02732859e7db7b64f4d1cb354 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests the debconf forwarding"""
import unittest
from gi.repository import GLib

from aptdaemon import enums, client

DEBUG = False


class TransChainTest(unittest.TestCase):

    """These tests require an aptdaemon running with the dummy worker:
    # sudo aptd -td --dummy
    """

    def setUp(self):
        self.loop = GLib.MainLoop()
        self.client = client.AptClient()

    def _test_working(self):
        def on_finished(trans, exit):
            self.loop.quit()
        trans1 = self.client.upgrade_packages(["huhu"])
        trans2 = self.client.upgrade_packages(["lala"])
        trans3 = self.client.upgrade_packages(["huhu"])
        trans2.run_after(trans1)
        trans3.run_after(trans2)
        trans1.run()
        trans3.connect("finished", on_finished)
        self.loop.run()
        self.assertTrue(trans1.exit == enums.EXIT_SUCCESS)
        self.assertTrue(trans2.exit == enums.EXIT_SUCCESS)
        self.assertTrue(trans3.exit == enums.EXIT_SUCCESS)

    def _test_fail_after(self):
        def on_finished(trans, exit):
            self.loop.quit()
        trans1 = self.client.update_cache()
        trans2 = self.client.upgrade_packages(["huhululu"])
        trans3 = self.client.upgrade_packages(["huhululu"])
        trans2.run_after(trans1)
        trans3.run_after(trans2)
        trans1.run()
        trans3.connect("finished", on_finished)
        self.loop.run()
        self.assertTrue(trans1.exit == enums.EXIT_FAILED)
        self.assertTrue(trans2.exit == enums.EXIT_PREVIOUS_FAILED)
        self.assertTrue(trans3.exit == enums.EXIT_PREVIOUS_FAILED)


if __name__ == "__main__":
    import logging
    if DEBUG:
        logging.basicConfig(level=logging.DEBUG)
    unittest.main()

# vim: ts=4 et sts=4