Move StaginAPI into a module. Fix tests.
This commit is contained in:
parent
f7cff407d4
commit
1fb0752147
@ -27,7 +27,7 @@ Link the +osc-staging.py+ either to +~/.osc-plugins+ or +/var/lib/osc-plugins+
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
cd osc-plugin-factory
|
||||
ln -sr ./osc-staging.py ./stagingapi.py ~/.osc-plugins
|
||||
ln -sr ./osc-staging.py ./osclib ~/.osc-plugins
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Now you are done and all that is left is start using plugin, see help in
|
||||
|
@ -6,12 +6,18 @@
|
||||
# Distribute under GPLv2 or GPLv3
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
import osc
|
||||
from osc import cmdln
|
||||
from osc.core import *
|
||||
|
||||
from stagingapi import StagingApi
|
||||
|
||||
# Expand sys.path to search modules inside the pluging directory
|
||||
_plugin_dir = os.path.expanduser('~/.osc-plugins')
|
||||
sys.path.append(_plugin_dir)
|
||||
from osclib.stagingapi import StagingApi
|
||||
|
||||
|
||||
OSC_STAGING_VERSION='0.0.1'
|
||||
|
0
osclib/__init__.py
Normal file
0
osclib/__init__.py
Normal file
1
osclib/stagingapi.py
Symbolic link
1
osclib/stagingapi.py
Symbolic link
@ -0,0 +1 @@
|
||||
../stagingapi.py
|
1
oscs/osclib
Symbolic link
1
oscs/osclib
Symbolic link
@ -0,0 +1 @@
|
||||
../osclib
|
@ -17,6 +17,7 @@ except ImportError:
|
||||
import oscs
|
||||
import osc
|
||||
|
||||
|
||||
class TestApiCalls(unittest.TestCase):
|
||||
"""
|
||||
Tests for various api calls to ensure we return expected content
|
||||
@ -77,25 +78,21 @@ class TestApiCalls(unittest.TestCase):
|
||||
"""
|
||||
|
||||
# our content in the XML files
|
||||
ring_packages = {'AGGR-antlr': 'openSUSE:Factory:MainDesktops',
|
||||
'Botan': 'openSUSE:Factory:DVD',
|
||||
'DirectFB': 'openSUSE:Factory:Core',
|
||||
'zlib': 'openSUSE:Factory:Build'}
|
||||
ring_packages = {
|
||||
'elem-ring-0': 'openSUSE:Factory:Rings:0-Bootstrap',
|
||||
'elem-ring-1': 'openSUSE:Factory:Rings:1-MinimalX',
|
||||
}
|
||||
|
||||
# Initiate the pretty overrides
|
||||
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Build',
|
||||
'build-project.xml')
|
||||
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Rings:0-Bootstrap',
|
||||
'ring-0-project.xml')
|
||||
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Core',
|
||||
'core-project.xml')
|
||||
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:MainDesktops',
|
||||
'maindesktops-project.xml')
|
||||
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:DVD',
|
||||
'dvd-project.xml')
|
||||
'ring-1-project.xml')
|
||||
|
||||
# Create the api object
|
||||
api = oscs.StagingApi('http://localhost')
|
||||
self.assertEqual(ring_packages,
|
||||
api.ring_packages)
|
||||
with mock_generate_ring_packages():
|
||||
api = oscs.StagingApi('http://localhost')
|
||||
self.assertEqual(ring_packages, api.ring_packages)
|
||||
|
||||
@httpretty.activate
|
||||
def test_dispatch_open_requests(self):
|
||||
@ -103,8 +100,6 @@ class TestApiCalls(unittest.TestCase):
|
||||
Test dispatching and closure of non-ring packages
|
||||
"""
|
||||
|
||||
pkglist = []
|
||||
|
||||
# Initiate the pretty overrides
|
||||
self._register_pretty_url_get('http://localhost/search/request?match=state/@name=\'review\'+and+review[@by_group=\'factory-staging\'+and+@state=\'new\']',
|
||||
'open-requests.xml')
|
||||
@ -114,6 +109,8 @@ class TestApiCalls(unittest.TestCase):
|
||||
# If there is bug in the function we get assertion about closing more issues than we should
|
||||
self._register_pretty_url_post('http://localhost/request/220956?comment=No+need+for+staging%2C+not+in+tested+ring+project.&newstate=accepted&by_group=factory-staging&cmd=changereviewstate',
|
||||
'open-requests.xml')
|
||||
self._register_pretty_url_post('http://localhost/request/221625?comment=No+need+for+staging%2C+not+in+tested+ring+project.&newstate=accepted&by_group=factory-staging&cmd=changereviewstate',
|
||||
'open-requests.xml')
|
||||
|
||||
# Initiate the api with mocked rings
|
||||
with mock_generate_ring_packages():
|
||||
@ -194,8 +191,7 @@ class TestApiCalls(unittest.TestCase):
|
||||
# Here place all mockable functions
|
||||
@contextlib.contextmanager
|
||||
def mock_generate_ring_packages():
|
||||
with mock.patch('oscs.StagingApi._generate_ring_packages', return_value={'AGGR-antlr': 'openSUSE:Factory:MainDesktops',
|
||||
'Botan': 'openSUSE:Factory:DVD',
|
||||
'DirectFB': 'openSUSE:Factory:Core',
|
||||
'xf86-video-intel': 'openSUSE:Factory:Build'}):
|
||||
with mock.patch('oscs.StagingApi._generate_ring_packages', return_value={
|
||||
'elem-ring-0': 'openSUSE:Factory:Rings:0-Bootstrap',
|
||||
'elem-ring-1': 'openSUSE:Factory:Rings:1-MinimalX'}):
|
||||
yield
|
||||
|
3
tests/fixtures/ring-0-project.xml
vendored
Normal file
3
tests/fixtures/ring-0-project.xml
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<directory count='1'>
|
||||
<entry name="entry-ring-0"/>
|
||||
</directory>
|
3
tests/fixtures/ring-1-project.xml
vendored
Normal file
3
tests/fixtures/ring-1-project.xml
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<directory count='1'>
|
||||
<entry name="entry-ring-1"/>
|
||||
</directory>
|
Loading…
x
Reference in New Issue
Block a user