2022-07-28 12:28:33 +02:00
|
|
|
import os
|
|
|
|
|
2011-02-22 16:27:53 +01:00
|
|
|
import osc.core
|
|
|
|
import osc.oscerr
|
2022-07-28 12:28:33 +02:00
|
|
|
|
2022-02-17 13:28:47 +01:00
|
|
|
from .common import GET, PUT, OscTestCase
|
2022-07-28 12:28:33 +02:00
|
|
|
|
|
|
|
|
2022-02-17 13:28:47 +01:00
|
|
|
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'setlinkrev_fixtures')
|
2011-02-22 16:27:53 +01:00
|
|
|
|
|
|
|
def suite():
|
|
|
|
import unittest
|
2022-07-28 19:11:29 +02:00
|
|
|
return unittest.defaultTestLoader.loadTestsFromTestCase(TestSetLinkRev)
|
2011-02-22 16:27:53 +01:00
|
|
|
|
|
|
|
class TestSetLinkRev(OscTestCase):
|
|
|
|
def setUp(self):
|
2022-08-31 11:46:12 +02:00
|
|
|
super().setUp(copytree=False)
|
2011-02-22 16:27:53 +01:00
|
|
|
|
|
|
|
def _get_fixtures_dir(self):
|
|
|
|
return FIXTURES_DIR
|
|
|
|
|
|
|
|
@GET('http://localhost/source/osctest/simple/_link', file='simple_link')
|
|
|
|
@GET('http://localhost/source/srcprj/srcpkg?rev=latest', file='simple_filesremote')
|
|
|
|
@PUT('http://localhost/source/osctest/simple/_link',
|
|
|
|
exp='<link package="srcpkg" project="srcprj" rev="42" />', text='dummytext')
|
|
|
|
def test_simple1(self):
|
|
|
|
"""a simple set_link_rev call without revision"""
|
|
|
|
osc.core.set_link_rev('http://localhost', 'osctest', 'simple')
|
|
|
|
|
|
|
|
@GET('http://localhost/source/osctest/simple/_link', file='simple_link')
|
|
|
|
@PUT('http://localhost/source/osctest/simple/_link',
|
|
|
|
exp='<link package="srcpkg" project="srcprj" rev="42" />', text='dummytext')
|
|
|
|
def test_simple2(self):
|
|
|
|
"""a simple set_link_rev call with revision"""
|
|
|
|
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', '42')
|
|
|
|
|
2011-02-22 17:21:07 +01:00
|
|
|
@GET('http://localhost/source/osctest/simple/_link', file='noproject_link')
|
2011-03-21 16:53:48 +01:00
|
|
|
@GET('http://localhost/source/osctest/srcpkg?rev=latest&expand=1', file='expandedsrc_filesremote')
|
2011-02-22 16:27:53 +01:00
|
|
|
@PUT('http://localhost/source/osctest/simple/_link',
|
2012-03-02 16:10:36 +01:00
|
|
|
exp='<link package="srcpkg" rev="eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" vrev="1" />', text='dummytext')
|
2011-02-22 16:27:53 +01:00
|
|
|
def test_expandedsrc(self):
|
|
|
|
"""expand src package"""
|
2011-03-21 16:53:48 +01:00
|
|
|
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', expand=True)
|
2011-02-22 16:27:53 +01:00
|
|
|
|
2014-03-03 22:35:25 +01:00
|
|
|
@GET('http://localhost/source/osctest/simple/_link', file='link_with_rev')
|
2014-05-16 11:58:36 +02:00
|
|
|
@GET('http://localhost/source/srcprj/srcpkg?rev=latest', file='simple_filesremote')
|
2014-03-03 22:35:25 +01:00
|
|
|
@PUT('http://localhost/source/osctest/simple/_link',
|
2014-05-16 11:58:36 +02:00
|
|
|
exp='<link package="srcpkg" project="srcprj" rev="42" />', text='dummytext')
|
2014-03-03 22:35:25 +01:00
|
|
|
def test_existingrev(self):
|
2014-05-16 11:58:36 +02:00
|
|
|
"""link already has a rev attribute, update it to current version"""
|
2014-03-03 22:35:25 +01:00
|
|
|
# we could also avoid the superfluous PUT
|
|
|
|
osc.core.set_link_rev('http://localhost', 'osctest', 'simple')
|
|
|
|
|
|
|
|
@GET('http://localhost/source/osctest/simple/_link', file='link_with_rev')
|
2014-05-16 11:58:36 +02:00
|
|
|
@GET('http://localhost/source/srcprj/srcpkg?rev=latest&expand=1', file='expandedsrc_filesremote')
|
2014-03-03 22:35:25 +01:00
|
|
|
@PUT('http://localhost/source/osctest/simple/_link',
|
|
|
|
exp='<link package="srcpkg" project="srcprj" rev="eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" vrev="1" />',
|
|
|
|
text='dummytext')
|
|
|
|
def test_expandexistingrev(self):
|
2014-05-16 11:58:36 +02:00
|
|
|
"""link already has a rev attribute, update it to current version"""
|
2014-03-03 22:35:25 +01:00
|
|
|
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', expand=True)
|
|
|
|
|
2011-02-22 16:27:53 +01:00
|
|
|
@GET('http://localhost/source/osctest/simple/_link', file='simple_link')
|
2014-03-03 21:54:59 +01:00
|
|
|
@GET('http://localhost/source/srcprj/srcpkg?rev=latest&expand=1', text='conflict in file merge', code=400)
|
2011-02-22 16:27:53 +01:00
|
|
|
def test_linkerror(self):
|
|
|
|
"""link is broken"""
|
2022-07-28 12:28:33 +02:00
|
|
|
from urllib.error import HTTPError
|
2014-03-03 21:54:59 +01:00
|
|
|
# the backend returns status 400 if we try to expand a broken _link
|
2013-04-09 14:22:45 +02:00
|
|
|
self.assertRaises(HTTPError, osc.core.set_link_rev, 'http://localhost', 'osctest', 'simple', expand=True)
|
2011-02-22 16:27:53 +01:00
|
|
|
|
|
|
|
@GET('http://localhost/source/osctest/simple/_link', file='rev_link')
|
|
|
|
@PUT('http://localhost/source/osctest/simple/_link',
|
|
|
|
exp='<link package="srcpkg" project="srcprj" />', text='dummytext')
|
|
|
|
def test_deleterev(self):
|
|
|
|
"""delete rev attribute from link xml"""
|
|
|
|
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', revision=None)
|
|
|
|
|
2014-03-03 21:54:59 +01:00
|
|
|
@GET('http://localhost/source/osctest/simple/_link', file='md5_rev_link')
|
|
|
|
@PUT('http://localhost/source/osctest/simple/_link',
|
|
|
|
exp='<link package="srcpkg" project="srcprj" />', text='dummytext')
|
|
|
|
def test_deleterev(self):
|
|
|
|
"""delete rev and vrev attribute from link xml"""
|
|
|
|
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', revision=None)
|
|
|
|
|
2011-02-22 16:27:53 +01:00
|
|
|
@GET('http://localhost/source/osctest/simple/_link', file='simple_link')
|
|
|
|
@PUT('http://localhost/source/osctest/simple/_link',
|
|
|
|
exp='<link package="srcpkg" project="srcprj" />', text='dummytext')
|
|
|
|
def test_deleterevnonexistent(self):
|
|
|
|
"""delete non existent rev attribute from link xml"""
|
|
|
|
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', revision=None)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import unittest
|
|
|
|
unittest.main()
|