1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-15 08:36:13 +01:00
github.com_openSUSE_osc/tests/test_package_status.py

92 lines
3.0 KiB
Python
Raw Normal View History

import os
2022-09-09 11:46:28 +02:00
import unittest
import osc.core
import osc.oscerr
2022-02-17 13:28:47 +01:00
from .common import OscTestCase
2022-02-17 13:28:47 +01:00
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
2022-09-12 13:43:10 +02:00
def suite():
return unittest.defaultTestLoader.loadTestsFromTestCase(TestPackageStatus)
2022-09-12 13:43:10 +02:00
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'),
2022-09-12 13:43:10 +02:00
('!', '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)
2022-09-12 13:43:10 +02:00
if __name__ == '__main__':
unittest.main()