openSUSE-release-tools/tests/select_tests.py

50 lines
1.5 KiB
Python
Raw Normal View History

2014-03-04 12:45:44 +01:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (C) 2014 tchvatal@suse.cz, openSUSE.org
# Distribute under GPLv2 or later
import sys
import unittest
import httpretty
import time
from obs import OBS
from osc import oscerr
2014-03-04 15:00:25 +01:00
from osclib.select_command import SelectCommand
2014-03-04 12:45:44 +01:00
class TestSelect(unittest.TestCase):
2014-03-04 15:00:25 +01:00
2014-03-04 12:45:44 +01:00
def setUp(self):
"""
Initialize the configuration
"""
self.obs = OBS()
@httpretty.activate
2014-03-04 15:00:25 +01:00
def test_old_frozen(self):
2014-03-04 12:45:44 +01:00
self.obs.register_obs()
self.assertEqual(self.obs.api.prj_frozen_enough('openSUSE:Factory:Staging:A'), False)
self.assertEqual(True, SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:A', ['gcc']))
self.assertEqual(self.obs.api.prj_frozen_enough('openSUSE:Factory:Staging:A'), True)
2014-03-04 12:45:44 +01:00
2014-03-04 15:00:25 +01:00
@httpretty.activate
def test_no_matches(self):
self.obs.register_obs()
2014-03-04 12:45:44 +01:00
# search for requests
with self.assertRaises(oscerr.WrongArgs) as cm:
2014-03-04 16:32:15 +01:00
SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:B', ['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
@httpretty.activate
def test_selected(self):
self.obs.register_obs()
# make sure the project is frozen recently for other tests
self.obs.responses['GET']['/request'] = 'systemd-search-results.xml'
ret = SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:B', ['systemd'])
2014-03-04 15:00:25 +01:00
self.assertEqual(True, ret)