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()
|
2014-03-07 15:10:04 +01:00
|
|
|
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
|
|
|
|
|
2014-03-06 10:44:52 +01:00
|
|
|
self.obs.responses['GET']['/request'] = 'systemd-search-results.xml'
|
2014-03-06 16:59:27 +01:00
|
|
|
ret = SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:B', ['systemd'])
|
2014-03-04 15:00:25 +01:00
|
|
|
self.assertEqual(True, ret)
|