File: test_package_status.py

package info (click to toggle)
osc 0.164.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,308 kB
  • sloc: python: 20,832; sh: 1,848; perl: 366; xml: 157; csh: 14; makefile: 9
file content (86 lines) | stat: -rw-r--r-- 3,061 bytes parent folder | download | duplicates (6)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import osc.core
import osc.oscerr
import os
from common import OscTestCase

FIXTURES_DIR = os.path.join(os.getcwd(), 'project_package_status_fixtures')

def suite():
    import unittest
    return unittest.makeSuite(TestPackageStatus)

class TestPackageStatus(OscTestCase):
    def _get_fixtures_dir(self):
        return FIXTURES_DIR

    def test_allfiles(self):
        """get the status of all files in the wc"""
        self._change_to_pkg('simple')
        p = osc.core.Package('.')
        exp_st = [('A', 'add'), ('?', 'exists'), ('D', 'foo'), ('!', 'merge'), ('R', 'missing'),
            ('!', 'missing_added'), ('M', 'nochange'), ('S', 'skipped'), (' ', 'test')]
        st = p.get_status()
        self.assertEqual(exp_st, st)

    def test_todo(self):
        """
        get the status of some files in the wc.
        """
        self._change_to_pkg('simple')
        p = osc.core.Package('.')
        p.todo = ['test', 'missing_added', 'foo']
        exp_st = [('D', 'foo'), ('!', 'missing_added')]
        st = p.get_status(False, ' ')
        self.assertEqual(exp_st, st)

    def test_todo_noexcl(self):
        """ get the status of some files in the wc. """
        self._change_to_pkg('simple')
        p = osc.core.Package('.')
        p.todo = ['test', 'missing_added', 'foo']
        exp_st = [('D', 'foo'), ('!', 'missing_added'), (' ', 'test')]
        st = p.get_status()
        self.assertEqual(exp_st, st)

    def test_exclude_state(self):
        """get the status of all files in the wc but exclude some states"""
        self._change_to_pkg('simple')
        p = osc.core.Package('.')
        exp_st = [('A', 'add'), ('?', 'exists'), ('D', 'foo')]
        st = p.get_status(False, '!', 'S', ' ', 'M', 'R')
        self.assertEqual(exp_st, st)

    def test_nonexistent(self):
        """get the status of a non existent file"""
        self._change_to_pkg('simple')
        p = osc.core.Package('.')
        p.todo = ['doesnotexist']
        self.assertRaises(osc.oscerr.OscIOError, p.get_status)

    def test_conflict(self):
        """get status of the wc (one file in conflict state)"""
        self._change_to_pkg('conflict')
        p = osc.core.Package('.')
        exp_st = [('C', 'conflict'), ('?', 'exists'), (' ', 'test')]
        st = p.get_status()
        self.assertEqual(exp_st, st)

    def test_excluded(self):
        """get status of the wc (ignore excluded files); package has state ' '"""
        self._change_to_pkg('excluded')
        p = osc.core.Package('.')
        exp_st = [('?', 'exists'), ('M', 'modified')]
        st = p.get_status(False, ' ')
        self.assertEqual(exp_st, st)

    def test_noexcluded(self):
        """get status of the wc (include excluded files)"""
        self._change_to_pkg('excluded')
        p = osc.core.Package('.')
        exp_st = [('?', '_linkerror'), ('?', 'exists'), ('?', 'foo.orig'), ('M', 'modified'), (' ', 'test')]
        st = p.get_status(True)
        self.assertEqual(exp_st, st)

if __name__ == '__main__':
    import unittest
    unittest.main()