1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

- added new testcases in order to test the status methods for projects and packages

This commit is contained in:
Marcus Huewe 2010-12-22 23:12:24 +01:00
parent f4d3648c8e
commit f8eae74898
64 changed files with 439 additions and 0 deletions

View File

@ -0,0 +1,104 @@
[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
passx = QlpoOTFBWSZTWeTSblkAAAGBgAIBygAgADDACGNEHxaYXckU4UJDk0m5ZA==
# 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

View File

@ -0,0 +1 @@
http://localhost

View File

@ -0,0 +1,9 @@
<project name="osctest">
<package name="conflict" state=" " />
<package name="simple" state=" " />
<package name="added" state="A" />
<package name="deleted" state="D" />
<package name="missing" state="!" />
<package name="added_deleted" state="A" />
<package name="deleted_deleted" state="D" />
</project>

View File

@ -0,0 +1 @@
osctest

View File

@ -0,0 +1 @@
http://localhost

View File

@ -0,0 +1 @@
<directory />

View File

@ -0,0 +1 @@
added

View File

@ -0,0 +1 @@
osctest

View File

@ -0,0 +1 @@
new

View File

@ -0,0 +1 @@
http://localhost

View File

@ -0,0 +1,4 @@
<directory name="conflict" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
<entry md5="2abd19de6a38ff2890af64f453df96b1" mtime="1282047303" name="conflict" size="22" />
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
</directory>

View File

@ -0,0 +1 @@
conflict

View File

@ -0,0 +1 @@
conflict

View File

@ -0,0 +1 @@
osctest

View File

@ -0,0 +1 @@
This file did change.

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
Inconflict

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
http://localhost

View File

@ -0,0 +1,4 @@
<directory name="conflict" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
<entry md5="2abd19de6a38ff2890af64f453df96b1" mtime="1282047303" name="modified" size="22" />
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
</directory>

View File

@ -0,0 +1 @@
deleted

View File

@ -0,0 +1 @@
osctest

View File

@ -0,0 +1,2 @@
modified
test

View File

@ -0,0 +1 @@
This file did change.

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
http://localhost

View File

@ -0,0 +1,4 @@
<directory name="conflict" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
<entry md5="2abd19de6a38ff2890af64f453df96b1" mtime="1282047303" name="modified" size="22" />
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
</directory>

View File

@ -0,0 +1 @@
excluded

View File

@ -0,0 +1 @@
osctest

View File

@ -0,0 +1 @@
This file did change.

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
file

View File

@ -0,0 +1 @@
modified

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
http://localhost

View File

@ -0,0 +1,8 @@
<directory name="simple" rev="1" srcmd5="2df1eacfe03a3bec2112529e7f4dc39a" vrev="1">
<entry md5="0d62ceea6020d75154078a20d8c9f9ba" mtime="1282047302" name="foo" size="23" />
<entry md5="17b9e9e1a032ed44e7a584dc6303ffa8" mtime="1282047303" name="merge" size="48" />
<entry md5="676513fde5797c3785164942c97dfec1" mtime="1283506309" name="missing" size="8" />
<entry md5="7efa70f68983fad1cf487f69dedf93e9" mtime="1282047303" name="nochange" size="25" />
<entry md5="d8e8fca2dc0f896fd7cb4cb0031ba249" mtime="1283505591" name="test" size="5" />
<entry md5="ffffffffffffffffffffffffffffffff" mtime="1111111111" name="skipped" size="100" skipped="true" />
</directory>

View File

@ -0,0 +1 @@
simple

View File

@ -0,0 +1 @@
osctest

View File

@ -0,0 +1,3 @@
add
missing
missing_added

View File

@ -0,0 +1 @@
This is a simple test.

View File

@ -0,0 +1,4 @@
Is it
possible to
merge this file?
I hope so...

View File

@ -0,0 +1 @@
missing

View File

@ -0,0 +1 @@
This file didn't change.

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
added file

View File

@ -0,0 +1 @@
replaced

View File

@ -0,0 +1 @@
This file did change.

View File

@ -0,0 +1 @@
test

View File

@ -9,6 +9,8 @@ import test_init_package
import test_init_project
import test_commit
import test_repairwc
import test_package_status
import test_project_status
suite = unittest.TestSuite()
suite.addTests(test_addfiles.suite())
@ -20,5 +22,7 @@ suite.addTests(test_init_package.suite())
suite.addTests(test_init_project.suite())
suite.addTests(test_commit.suite())
suite.addTests(test_repairwc.suite())
suite.addTests(test_package_status.suite())
suite.addTests(test_project_status.suite())
result = unittest.TextTestRunner(verbosity=1).run(suite)
sys.exit(not result.wasSuccessful())

View File

@ -0,0 +1,86 @@
import osc.core
import osc.oscerr
import os
from common import OscTestCase
FIXTURES_DIR = os.path.join(os.getcwd(), 'project_package_status_fixtures')
def suite():
import unittest
return unittest.makeSuite(TestPackageStatus)
class TestPackageStatus(OscTestCase):
def _get_fixtures_dir(self):
return FIXTURES_DIR
def test_allfiles(self):
"""get the status of all files in the wc"""
self._change_to_pkg('simple')
p = osc.core.Package('.')
exp_st = [('A', 'add'), ('?', 'exists'), ('D', 'foo'), ('!', 'merge'), ('R', 'missing'),
('!', 'missing_added'), ('M', 'nochange'), ('S', 'skipped'), (' ', 'test')]
st = p.get_status()
self.assertEqual(exp_st, st)
def test_todo(self):
"""
get the status of some files in the wc.
"""
self._change_to_pkg('simple')
p = osc.core.Package('.')
p.todo = ['test', 'missing_added', 'foo']
exp_st = [('D', 'foo'), ('!', 'missing_added')]
st = p.get_status(False, ' ')
self.assertEqual(exp_st, st)
def test_todo_noexcl(self):
""" get the status of some files in the wc. """
self._change_to_pkg('simple')
p = osc.core.Package('.')
p.todo = ['test', 'missing_added', 'foo']
exp_st = [('D', 'foo'), ('!', 'missing_added'), (' ', 'test')]
st = p.get_status()
self.assertEqual(exp_st, st)
def test_exclude_state(self):
"""get the status of all files in the wc but exclude some states"""
self._change_to_pkg('simple')
p = osc.core.Package('.')
exp_st = [('A', 'add'), ('?', 'exists'), ('D', 'foo')]
st = p.get_status(False, '!', 'S', ' ', 'M', 'R')
self.assertEqual(exp_st, st)
def test_nonexistent(self):
"""get the status of a non existent file"""
self._change_to_pkg('simple')
p = osc.core.Package('.')
p.todo = ['doesnotexist']
self.assertRaises(osc.oscerr.OscIOError, p.get_status)
def test_conflict(self):
"""get status of the wc (one file in conflict state)"""
self._change_to_pkg('conflict')
p = osc.core.Package('.')
exp_st = [('C', 'conflict'), ('?', 'exists'), (' ', 'test')]
st = p.get_status()
self.assertEqual(exp_st, st)
def test_excluded(self):
"""get status of the wc (ignore excluded files); package has state ' '"""
self._change_to_pkg('excluded')
p = osc.core.Package('.')
exp_st = [('?', 'exists'), ('M', 'modified')]
st = p.get_status(False, ' ')
self.assertEqual(exp_st, st)
def test_noexcluded(self):
"""get status of the wc (include excluded files)"""
self._change_to_pkg('excluded')
p = osc.core.Package('.')
exp_st = [('?', '_linkerror'), ('?', 'exists'), ('?', 'foo.orig'), ('M', 'modified'), (' ', 'test')]
st = p.get_status(True)
self.assertEqual(exp_st, st)
if __name__ == '__main__':
import unittest
unittest.main()

View File

@ -0,0 +1,161 @@
import osc.core
import osc.oscerr
import os
from common import OscTestCase
FIXTURES_DIR = os.path.join(os.getcwd(), 'project_package_status_fixtures')
def suite():
import unittest
return unittest.makeSuite(TestProjectStatus)
class TestProjectStatus(OscTestCase):
def _get_fixtures_dir(self):
return FIXTURES_DIR
def test_simple(self):
"""get the status of a package with state ' '"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
exp_st = ' '
st = prj.status('simple')
self.assertEqual(exp_st, st)
def test_added(self):
"""get the status of an added package"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
exp_st = 'A'
st = prj.status('added')
self.assertEqual(exp_st, st)
def test_deleted(self):
"""get the status of a deleted package"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
exp_st = 'D'
st = prj.status('deleted')
self.assertEqual(exp_st, st)
def test_added_deleted(self):
"""
get the status of a package which was added and deleted
afterwards (with a non osc command)
"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
exp_st = '!'
st = prj.status('added_deleted')
self.assertEqual(exp_st, st)
def test_missing(self):
"""
get the status of a package with state " "
which was removed by a non osc command
"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
exp_st = '!'
st = prj.status('missing')
self.assertEqual(exp_st, st)
def test_deleted_deleted(self):
"""
get the status of a package which was deleted (with an
osc command) and afterwards the package directory was
deleted with a non osc command
"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
exp_st = 'D'
st = prj.status('deleted_deleted')
self.assertEqual(exp_st, st)
def test_unversioned_exists(self):
"""get the status of an unversioned package"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
exp_st = '?'
st = prj.status('excluded')
self.assertEqual(exp_st, st)
def test_unversioned_nonexistent(self):
"""get the status of an unversioned, nonexistent package"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
self.assertRaises(osc.oscerr.OscIOError, prj.status, 'doesnotexist')
def test_get_status(self):
"""get the status of the complete project"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
exp_st = [(' ', 'conflict'), (' ', 'simple'), ('A', 'added'), ('D', 'deleted'),
('!', 'missing'), ('!', 'added_deleted'), ('D', 'deleted_deleted'), ('?', 'excluded')]
st = prj.get_status()
self.assertEqual(exp_st, st)
def test_get_status_excl(self):
"""get the status of the complete project (exclude some states)"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
exp_st = [('A', 'added'), ('!', 'missing'), ('!', 'added_deleted')]
st = prj.get_status('D', ' ', '?')
self.assertEqual(exp_st, st)
def test_get_pacobj_simple(self):
"""package exists"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
p = prj.get_pacobj('simple')
self.assertTrue(isinstance(p, osc.core.Package))
self.assertEqual(p.name, 'simple')
def test_get_pacobj_added(self):
"""package has state 'A', also test pac_kwargs"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
p = prj.get_pacobj('added', progress_obj={})
self.assertTrue(isinstance(p, osc.core.Package))
self.assertEqual(p.name, 'added')
self.assertEqual(p.progress_obj, {})
def test_get_pacobj_deleted(self):
"""package has state 'D' and exists, also test pac_args"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
p = prj.get_pacobj('deleted', {})
self.assertTrue(isinstance(p, osc.core.Package))
self.assertEqual(p.name, 'deleted')
self.assertEqual(p.progress_obj, {})
def test_get_pacobj_missing(self):
"""package is missing"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
p = prj.get_pacobj('missing')
self.assertTrue(isinstance(p, type(None)))
def test_get_pacobj_deleted_deleted(self):
"""package has state 'D' and does not exist"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
p = prj.get_pacobj('deleted_deleted')
self.assertTrue(isinstance(p, type(None)))
def test_get_pacobj_unversioned(self):
"""package/dir has state '?'"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
p = prj.get_pacobj('excluded')
self.assertTrue(isinstance(p, type(None)))
def test_get_pacobj_nonexistent(self):
"""package/dir does not exist"""
self._change_to_pkg('.')
prj = osc.core.Project('.', getPackageList=False)
p = prj.get_pacobj('doesnotexist')
self.assertTrue(isinstance(p, type(None)))
if __name__ == '__main__':
import unittest
unittest.main()