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
|
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
|
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
|
# Distribute under GPLv2 or GPLv3
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os.path
|
||||||
|
import sys
|
||||||
|
|
||||||
import osc
|
import osc
|
||||||
from osc import cmdln
|
from osc import cmdln
|
||||||
from osc.core import *
|
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'
|
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 oscs
|
||||||
import osc
|
import osc
|
||||||
|
|
||||||
|
|
||||||
class TestApiCalls(unittest.TestCase):
|
class TestApiCalls(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
Tests for various api calls to ensure we return expected content
|
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
|
# our content in the XML files
|
||||||
ring_packages = {'AGGR-antlr': 'openSUSE:Factory:MainDesktops',
|
ring_packages = {
|
||||||
'Botan': 'openSUSE:Factory:DVD',
|
'elem-ring-0': 'openSUSE:Factory:Rings:0-Bootstrap',
|
||||||
'DirectFB': 'openSUSE:Factory:Core',
|
'elem-ring-1': 'openSUSE:Factory:Rings:1-MinimalX',
|
||||||
'zlib': 'openSUSE:Factory:Build'}
|
}
|
||||||
|
|
||||||
# Initiate the pretty overrides
|
# Initiate the pretty overrides
|
||||||
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Build',
|
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Rings:0-Bootstrap',
|
||||||
'build-project.xml')
|
'ring-0-project.xml')
|
||||||
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Core',
|
self._register_pretty_url_get('http://localhost/source/openSUSE:Factory:Core',
|
||||||
'core-project.xml')
|
'ring-1-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')
|
|
||||||
|
|
||||||
# Create the api object
|
# Create the api object
|
||||||
api = oscs.StagingApi('http://localhost')
|
with mock_generate_ring_packages():
|
||||||
self.assertEqual(ring_packages,
|
api = oscs.StagingApi('http://localhost')
|
||||||
api.ring_packages)
|
self.assertEqual(ring_packages, api.ring_packages)
|
||||||
|
|
||||||
@httpretty.activate
|
@httpretty.activate
|
||||||
def test_dispatch_open_requests(self):
|
def test_dispatch_open_requests(self):
|
||||||
@ -103,8 +100,6 @@ class TestApiCalls(unittest.TestCase):
|
|||||||
Test dispatching and closure of non-ring packages
|
Test dispatching and closure of non-ring packages
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pkglist = []
|
|
||||||
|
|
||||||
# Initiate the pretty overrides
|
# 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\']',
|
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')
|
'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
|
# 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',
|
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')
|
'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
|
# Initiate the api with mocked rings
|
||||||
with mock_generate_ring_packages():
|
with mock_generate_ring_packages():
|
||||||
@ -194,8 +191,7 @@ class TestApiCalls(unittest.TestCase):
|
|||||||
# Here place all mockable functions
|
# Here place all mockable functions
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def mock_generate_ring_packages():
|
def mock_generate_ring_packages():
|
||||||
with mock.patch('oscs.StagingApi._generate_ring_packages', return_value={'AGGR-antlr': 'openSUSE:Factory:MainDesktops',
|
with mock.patch('oscs.StagingApi._generate_ring_packages', return_value={
|
||||||
'Botan': 'openSUSE:Factory:DVD',
|
'elem-ring-0': 'openSUSE:Factory:Rings:0-Bootstrap',
|
||||||
'DirectFB': 'openSUSE:Factory:Core',
|
'elem-ring-1': 'openSUSE:Factory:Rings:1-MinimalX'}):
|
||||||
'xf86-video-intel': 'openSUSE:Factory:Build'}):
|
|
||||||
yield
|
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