mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-25 17:36:13 +01:00
- added testcases for "set_link_rev"
This commit is contained in:
parent
208230bc58
commit
40928d2460
5
tests/setlinkrev_fixtures/baserev_filesremote
Normal file
5
tests/setlinkrev_fixtures/baserev_filesremote
Normal file
@ -0,0 +1,5 @@
|
||||
<directory name="srcpkg" rev="42" srcmd5="ffffffffffffffffffffffffffffffff" vrev="1">
|
||||
<linkinfo project="srcsrcprj" package="srcsrcpkg" srcmd5="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" baserev="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" xsrcmd5="abcdeeeeeeeeeeeeeeeeeeeeeeeeeeee" lsrcmd5="cccccccccccccccccccccccccccccccc" />
|
||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="_link" size="23" />
|
||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||
</directory>
|
5
tests/setlinkrev_fixtures/expandedsrc_filesremote
Normal file
5
tests/setlinkrev_fixtures/expandedsrc_filesremote
Normal file
@ -0,0 +1,5 @@
|
||||
<directory name="srcpkg" rev="42" srcmd5="ffffffffffffffffffffffffffffffff" vrev="1">
|
||||
<linkinfo project="srcsrcprj" package="srcsrcpkg" srcmd5="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" baserev="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" xsrcmd5="eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" lsrcmd5="cccccccccccccccccccccccccccccccc" />
|
||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="_link" size="23" />
|
||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||
</directory>
|
5
tests/setlinkrev_fixtures/linkerror_filesremote
Normal file
5
tests/setlinkrev_fixtures/linkerror_filesremote
Normal file
@ -0,0 +1,5 @@
|
||||
<directory name="srcpkg" rev="42" srcmd5="ffffffffffffffffffffffffffffffff" vrev="1">
|
||||
<linkinfo project="srcsrcprj" package="srcsrcpkg" baserev="704450154e7f9ae6c27f0f8317a69781" xsrcmd5="b484571d7189720a5dc8e81bd1ca58ca" error="conflict in file merge" />
|
||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="_link" size="23" />
|
||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||
</directory>
|
103
tests/setlinkrev_fixtures/oscrc
Normal file
103
tests/setlinkrev_fixtures/oscrc
Normal file
@ -0,0 +1,103 @@
|
||||
[general]
|
||||
# URL to access API server, e.g. https://api.opensuse.org
|
||||
# you also need a section [https://api.opensuse.org] with the credentials
|
||||
apiurl = http://localhost
|
||||
# Downloaded packages are cached here. Must be writable by you.
|
||||
#packagecachedir = /var/tmp/osbuild-packagecache
|
||||
# Wrapper to call build as root (sudo, su -, ...)
|
||||
#su-wrapper = su -c
|
||||
# rootdir to setup the chroot environment
|
||||
# can contain %(repo)s, %(arch)s, %(project)s and %(package)s for replacement, e.g.
|
||||
# /srv/oscbuild/%(repo)s-%(arch)s or
|
||||
# /srv/oscbuild/%(repo)s-%(arch)s-%(project)s-%(package)s
|
||||
#build-root = /var/tmp/build-root
|
||||
# compile with N jobs (default: "getconf _NPROCESSORS_ONLN")
|
||||
#build-jobs = N
|
||||
# build-type to use - values can be (depending on the capabilities of the 'build' script)
|
||||
# empty - chroot build
|
||||
# kvm - kvm VM build (needs build-device, build-swap, build-memory)
|
||||
# xen - xen VM build (needs build-device, build-swap, build-memory)
|
||||
# experimental:
|
||||
# qemu - qemu VM build
|
||||
# lxc - lxc build
|
||||
#build-type =
|
||||
# build-device is the disk-image file to use as root for VM builds
|
||||
# e.g. /var/tmp/FILE.root
|
||||
#build-device = /var/tmp/FILE.root
|
||||
# build-swap is the disk-image to use as swap for VM builds
|
||||
# e.g. /var/tmp/FILE.swap
|
||||
#build-swap = /var/tmp/FILE.swap
|
||||
# build-memory is the amount of memory used in the VM
|
||||
# value in MB - e.g. 512
|
||||
#build-memory = 512
|
||||
# build-vmdisk-rootsize is the size of the disk-image used as root in a VM build
|
||||
# values in MB - e.g. 4096
|
||||
#build-vmdisk-rootsize = 4096
|
||||
# build-vmdisk-swapsize is the size of the disk-image used as swap in a VM build
|
||||
# values in MB - e.g. 1024
|
||||
#build-vmdisk-swapsize = 1024
|
||||
# Numeric uid:gid to assign to the "abuild" user in the build-root
|
||||
# or "caller" to use the current users uid:gid
|
||||
# This is convenient when sharing the buildroot with ordinary userids
|
||||
# on the host.
|
||||
# This should not be 0
|
||||
# build-uid =
|
||||
# extra packages to install when building packages locally (osc build)
|
||||
# this corresponds to osc build's -x option and can be overridden with that
|
||||
# -x '' can also be given on the command line to override this setting, or
|
||||
# you can have an empty setting here.
|
||||
#extra-pkgs = vim gdb strace
|
||||
# build platform is used if the platform argument is omitted to osc build
|
||||
#build_repository = openSUSE_Factory
|
||||
# default project for getpac or bco
|
||||
#getpac_default_project = openSUSE:Factory
|
||||
# alternate filesystem layout: have multiple subdirs, where colons were.
|
||||
#checkout_no_colon = 0
|
||||
# local files to ignore with status, addremove, ....
|
||||
#exclude_glob = .osc CVS .svn .* _linkerror *~ #*# *.orig *.bak *.changes.*
|
||||
# keep passwords in plaintext. If you see this comment, your osc
|
||||
# already uses the encrypted password, and only keeps them in plain text
|
||||
# for backwards compatibility. Default will change to 0 in future releases.
|
||||
# You can remove the plaintext password without harm, if you do not need
|
||||
# backwards compatibility.
|
||||
#plaintext_passwd = 1
|
||||
# limit the age of requests shown with 'osc req list'.
|
||||
# this is a default only, can be overridden by 'osc req list -D NNN'
|
||||
# Use 0 for unlimted.
|
||||
#request_list_days = 0
|
||||
# show info useful for debugging
|
||||
#debug = 1
|
||||
# show HTTP traffic useful for debugging
|
||||
#http_debug = 1
|
||||
# Skip signature verification of packages used for build.
|
||||
#no_verify = 1
|
||||
# jump into the debugger in case of errors
|
||||
#post_mortem = 1
|
||||
# print call traces in case of errors
|
||||
#traceback = 1
|
||||
# use KDE/Gnome/MacOS/Windows keyring for credentials if available
|
||||
#use_keyring = 1
|
||||
# check for unversioned/removed files before commit
|
||||
#check_filelist = 1
|
||||
# check for pending requests after executing an action (e.g. checkout, update, commit)
|
||||
#check_for_request_on_action = 0
|
||||
# what to do with the source package if the submitrequest has been accepted. If
|
||||
# nothing is specified the API default is used
|
||||
#submitrequest_on_accept_action = cleanup|update|noupdate
|
||||
#review requests interactively (default: off)
|
||||
#request_show_review = 1
|
||||
# Directory with executables to validate sources, esp before committing
|
||||
#source_validator_directory = /usr/lib/osc/source_validators
|
||||
|
||||
[http://localhost]
|
||||
user=Admin
|
||||
pass=opensuse
|
||||
# set aliases for this apiurl
|
||||
# aliases = foo, bar
|
||||
# email used in .changes, unless the one from osc meta prj <user> will be used
|
||||
# email =
|
||||
# additional headers to pass to a request, e.g. for special authentication
|
||||
#http_headers = Host: foofoobar,
|
||||
# User: mumblegack
|
||||
# Force using of keyring for this API
|
||||
#keyring = 1
|
1
tests/setlinkrev_fixtures/rev_link
Normal file
1
tests/setlinkrev_fixtures/rev_link
Normal file
@ -0,0 +1 @@
|
||||
<link package="srcpkg" project="srcprj" rev="42" />
|
4
tests/setlinkrev_fixtures/simple_filesremote
Normal file
4
tests/setlinkrev_fixtures/simple_filesremote
Normal file
@ -0,0 +1,4 @@
|
||||
<directory name="srcpkg" rev="42" srcmd5="ffffffffffffffffffffffffffffffff" vrev="1">
|
||||
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
|
||||
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
|
||||
</directory>
|
1
tests/setlinkrev_fixtures/simple_link
Normal file
1
tests/setlinkrev_fixtures/simple_link
Normal file
@ -0,0 +1 @@
|
||||
<link package="srcpkg" project="srcprj" />
|
@ -12,6 +12,7 @@ import test_repairwc
|
||||
import test_package_status
|
||||
import test_project_status
|
||||
import test_request
|
||||
import test_setlinkrev
|
||||
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTests(test_addfiles.suite())
|
||||
@ -26,5 +27,6 @@ suite.addTests(test_repairwc.suite())
|
||||
suite.addTests(test_package_status.suite())
|
||||
suite.addTests(test_project_status.suite())
|
||||
suite.addTests(test_request.suite())
|
||||
suite.addTests(test_setlinkrev.suite())
|
||||
result = unittest.TextTestRunner(verbosity=1).run(suite)
|
||||
sys.exit(not result.wasSuccessful())
|
||||
|
71
tests/test_setlinkrev.py
Normal file
71
tests/test_setlinkrev.py
Normal file
@ -0,0 +1,71 @@
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
from common import GET, PUT, OscTestCase
|
||||
FIXTURES_DIR = os.path.join(os.getcwd(), 'setlinkrev_fixtures')
|
||||
|
||||
def suite():
|
||||
import unittest
|
||||
return unittest.makeSuite(TestSetLinkRev)
|
||||
|
||||
class TestSetLinkRev(OscTestCase):
|
||||
def setUp(self):
|
||||
OscTestCase.setUp(self, copytree=False)
|
||||
|
||||
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')
|
||||
|
||||
@GET('http://localhost/source/osctest/simple/_link', file='simple_link')
|
||||
@GET('http://localhost/source/srcprj/srcpkg?rev=latest', file='expandedsrc_filesremote')
|
||||
@PUT('http://localhost/source/osctest/simple/_link',
|
||||
exp='<link package="srcpkg" project="srcprj" rev="eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" />', text='dummytext')
|
||||
def test_expandedsrc(self):
|
||||
"""expand src package"""
|
||||
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', xsrcmd5=True)
|
||||
|
||||
@GET('http://localhost/source/osctest/simple/_link', file='simple_link')
|
||||
@GET('http://localhost/source/srcprj/srcpkg?linkrev=base&rev=latest', file='baserev_filesremote')
|
||||
@PUT('http://localhost/source/osctest/simple/_link',
|
||||
exp='<link package="srcpkg" project="srcprj" rev="abcdeeeeeeeeeeeeeeeeeeeeeeeeeeee" />', text='dummytext')
|
||||
def test_baserev(self):
|
||||
"""expanded baserev revision"""
|
||||
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', baserev=True)
|
||||
|
||||
@GET('http://localhost/source/osctest/simple/_link', file='simple_link')
|
||||
@GET('http://localhost/source/srcprj/srcpkg?rev=latest', file='linkerror_filesremote')
|
||||
def test_linkerror(self):
|
||||
"""link is broken"""
|
||||
self.assertRaises(osc.oscerr.LinkExpandError, osc.core.set_link_rev, 'http://localhost', 'osctest', 'simple', xsrcmd5=True)
|
||||
|
||||
@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)
|
||||
|
||||
@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()
|
Loading…
Reference in New Issue
Block a user