Split select test to separate file

This commit is contained in:
Michal Hrusecky 2014-03-04 12:45:44 +01:00 committed by Michal Hrusecky
parent 51aa975a39
commit 673d08b8a3
2 changed files with 63 additions and 28 deletions

View File

@ -364,31 +364,3 @@ class TestApiCalls(unittest.TestCase):
self.obs.responses['GET']['/source/openSUSE:Factory:Staging:U/_project'] = 'project-u-metalist.xml' self.obs.responses['GET']['/source/openSUSE:Factory:Staging:U/_project'] = 'project-u-metalist.xml'
self.assertTrue(self.obs.api.days_since_last_freeze('openSUSE:Factory:Staging:U') > 1000) self.assertTrue(self.obs.api.days_since_last_freeze('openSUSE:Factory:Staging:U') > 1000)
@httpretty.activate
def test_select(self):
"""
Test checking project status
"""
from osclib.select_command import SelectCommand
# Register OBS
self.obs.register_obs()
# old frozen
tmpl = Template(self.obs._get_fixture_content('project-a-metalist.xml'))
self.obs.responses['GET']['/source/openSUSE:Factory:Staging:A/_project'] = tmpl.substitute({'mtime': 1393152777})
self.assertEqual(False, SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:A', ['bash']))
# make sure the project is frozen recently for other tests
self.obs.responses['GET']['/source/openSUSE:Factory:Staging:A/_project'] = tmpl.substitute({'mtime': str(int(time.time()) - 1000) })
# search for requests
self.obs.responses['GET']['/request'] = '<collection matches="0"/>'
# TODO: it's actually 404 - but OBS class can't handle that ;(
self.obs.responses['GET']['/request/bash'] = '<collection matches="0"/>'
with self.assertRaises(oscerr.WrongArgs) as cm:
SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:A', ['bash'])
self.assertEqual(str(cm.exception), "No SR# found for: bash")

63
tests/select_tests.py Normal file
View File

@ -0,0 +1,63 @@
#!/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 string import Template
from obs import OBS
from osc import oscerr
class TestSelect(unittest.TestCase):
def setUp(self):
"""
Initialize the configuration
"""
self.obs = OBS()
def _get_fixture_path(self, filename):
"""
Return path for fixture
"""
return os.path.join(self._get_fixtures_dir(), filename)
def _get_fixtures_dir(self):
"""
Return path for fixtures
"""
return os.path.join(os.getcwd(), 'tests/fixtures')
@httpretty.activate
def test_select(self):
"""
Test checking project status
"""
from osclib.select_command import SelectCommand
# Register OBS
self.obs.register_obs()
# old frozen
tmpl = Template(self.obs._get_fixture_content('project-a-metalist.xml'))
self.obs.responses['GET']['/source/openSUSE:Factory:Staging:A/_project'] = tmpl.substitute({'mtime': 1393152777})
self.assertEqual(False, SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:A', ['bash']))
# make sure the project is frozen recently for other tests
self.obs.responses['GET']['/source/openSUSE:Factory:Staging:A/_project'] = tmpl.substitute({'mtime': str(int(time.time()) - 1000) })
# search for requests
self.obs.responses['GET']['/request'] = '<collection matches="0"/>'
# TODO: it's actually 404 - but OBS class can't handle that ;(
self.obs.responses['GET']['/request/bash'] = '<collection matches="0"/>'
with self.assertRaises(oscerr.WrongArgs) as cm:
SelectCommand(self.obs.api).perform('openSUSE:Factory:Staging:A', ['bash'])
self.assertEqual(str(cm.exception), "No SR# found for: bash")