openSUSE-release-tools/tests/select_tests.py

71 lines
2.4 KiB
Python
Raw Normal View History

2014-03-04 12:45:44 +01:00
import unittest
import os.path
2014-03-04 12:45:44 +01:00
from osc import oscerr
import osc.conf
from osclib.cache import Cache
from osclib.cache_manager import CacheManager
from osclib.comments import CommentAPI
from osclib.conf import Config
from osclib.core import package_list
2014-03-04 15:00:25 +01:00
from osclib.select_command import SelectCommand
from osclib.unselect_command import UnselectCommand
2014-06-23 15:03:16 +02:00
from osclib.stagingapi import StagingAPI
from osclib.memoize import memoize_session_reset
import logging
2014-03-04 12:45:44 +01:00
from mock import MagicMock
from . import OBSLocal
2014-06-23 15:03:16 +02:00
2014-03-04 12:45:44 +01:00
class TestSelect(unittest.TestCase):
2014-03-04 15:00:25 +01:00
def setUp(self):
super(TestSelect, self).setUp()
self.wf = OBSLocal.StagingWorkflow()
def tearDown(self):
del self.wf
super(TestSelect, self).tearDown()
2014-03-04 15:00:25 +01:00
def test_old_frozen(self):
self.wf.api.prj_frozen_enough = MagicMock(return_value=False)
# check it won't allow selecting
staging = self.wf.create_staging('Old')
self.assertEqual(False, SelectCommand(self.wf.api, staging.name).perform(['gcc']))
2014-07-01 09:29:03 +02:00
2014-03-04 15:00:25 +01:00
def test_no_matches(self):
staging = self.wf.create_staging('N', freeze=True)
2014-03-04 12:45:44 +01:00
# search for requests
with self.assertRaises(oscerr.WrongArgs) as cm:
SelectCommand(self.wf.api, staging.name).perform(['bash'])
2014-03-04 12:45:44 +01:00
self.assertEqual(str(cm.exception), "No SR# found for: bash")
2014-03-04 15:00:25 +01:00
def test_selected(self):
self.wf.setup_rings()
staging = self.wf.create_staging('S', freeze=True)
self.wf.create_submit_request('devel:wine', 'wine')
ret = SelectCommand(self.wf.api, staging.name).perform(['wine'])
self.assertEqual(True, ret)
def test_select_multiple_spec(self):
self.wf.setup_rings()
staging = self.wf.create_staging('A', freeze=True)
2014-03-04 15:00:25 +01:00
project = self.wf.create_project('devel:gcc')
package = OBSLocal.Package(name='gcc8', project=project)
package.create_commit(filename='gcc8.spec')
package.create_commit(filename='gcc8-tests.spec')
self.wf.submit_package(package)
ret = SelectCommand(self.wf.api, staging.name).perform(['gcc8'])
2014-03-04 15:00:25 +01:00
self.assertEqual(True, ret)
self.assertEqual(package_list(self.wf.apiurl, staging.name), ['gcc8', 'gcc8-tests'])
uc = UnselectCommand(self.wf.api)
2019-11-20 16:38:19 +01:00
self.assertIsNone(uc.perform(['gcc8'], False, None))
# no stale links
self.assertEqual([], package_list(self.wf.apiurl, staging.name))