From f8eae748987f3b2582253837673b0e8b63628225 Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Wed, 22 Dec 2010 23:12:24 +0100 Subject: [PATCH] - added new testcases in order to test the status methods for projects and packages --- tests/project_package_status_fixtures/oscrc | 104 +++++++++++ .../osctest/.osc/_apiurl | 1 + .../osctest/.osc/_packages | 9 + .../osctest/.osc/_project | 1 + .../osctest/added/.osc/_apiurl | 1 + .../osctest/added/.osc/_files | 1 + .../osctest/added/.osc/_osclib_version | 1 + .../osctest/added/.osc/_package | 1 + .../osctest/added/.osc/_project | 1 + .../osctest/added/.osc/_to_be_added | 1 + .../osctest/added/exists | 0 .../osctest/added/new | 1 + .../osctest/conflict/.osc/_apiurl | 1 + .../osctest/conflict/.osc/_files | 4 + .../osctest/conflict/.osc/_in_conflict | 1 + .../osctest/conflict/.osc/_osclib_version | 1 + .../osctest/conflict/.osc/_package | 1 + .../osctest/conflict/.osc/_project | 1 + .../osctest/conflict/.osc/conflict | 1 + .../osctest/conflict/.osc/test | 1 + .../osctest/conflict/conflict | 1 + .../osctest/conflict/exists | 0 .../osctest/conflict/test | 1 + .../osctest/deleted/.osc/_apiurl | 1 + .../osctest/deleted/.osc/_files | 4 + .../osctest/deleted/.osc/_osclib_version | 1 + .../osctest/deleted/.osc/_package | 1 + .../osctest/deleted/.osc/_project | 1 + .../osctest/deleted/.osc/_to_be_deleted | 2 + .../osctest/deleted/.osc/modified | 1 + .../osctest/deleted/.osc/test | 1 + .../osctest/excluded/.osc/_apiurl | 1 + .../osctest/excluded/.osc/_files | 4 + .../osctest/excluded/.osc/_osclib_version | 1 + .../osctest/excluded/.osc/_package | 1 + .../osctest/excluded/.osc/_project | 1 + .../osctest/excluded/.osc/modified | 1 + .../osctest/excluded/.osc/test | 1 + .../osctest/excluded/_linkerror | 0 .../osctest/excluded/dir/file | 1 + .../osctest/excluded/exists | 0 .../osctest/excluded/foo.orig | 0 .../osctest/excluded/modified | 1 + .../osctest/excluded/test | 1 + .../osctest/simple/.osc/_apiurl | 1 + .../osctest/simple/.osc/_files | 8 + .../osctest/simple/.osc/_osclib_version | 1 + .../osctest/simple/.osc/_package | 1 + .../osctest/simple/.osc/_project | 1 + .../osctest/simple/.osc/_to_be_added | 3 + .../osctest/simple/.osc/_to_be_deleted | 1 + .../osctest/simple/.osc/foo | 1 + .../osctest/simple/.osc/merge | 4 + .../osctest/simple/.osc/missing | 1 + .../osctest/simple/.osc/nochange | 1 + .../osctest/simple/.osc/test | 1 + .../osctest/simple/add | 1 + .../osctest/simple/exists | 0 .../osctest/simple/missing | 1 + .../osctest/simple/nochange | 1 + .../osctest/simple/test | 1 + tests/suite.py | 4 + tests/test_package_status.py | 86 ++++++++++ tests/test_project_status.py | 161 ++++++++++++++++++ 64 files changed, 439 insertions(+) create mode 100644 tests/project_package_status_fixtures/oscrc create mode 100644 tests/project_package_status_fixtures/osctest/.osc/_apiurl create mode 100644 tests/project_package_status_fixtures/osctest/.osc/_packages create mode 100644 tests/project_package_status_fixtures/osctest/.osc/_project create mode 100644 tests/project_package_status_fixtures/osctest/added/.osc/_apiurl create mode 100644 tests/project_package_status_fixtures/osctest/added/.osc/_files create mode 100644 tests/project_package_status_fixtures/osctest/added/.osc/_osclib_version create mode 100644 tests/project_package_status_fixtures/osctest/added/.osc/_package create mode 100644 tests/project_package_status_fixtures/osctest/added/.osc/_project create mode 100644 tests/project_package_status_fixtures/osctest/added/.osc/_to_be_added create mode 100644 tests/project_package_status_fixtures/osctest/added/exists create mode 100644 tests/project_package_status_fixtures/osctest/added/new create mode 100644 tests/project_package_status_fixtures/osctest/conflict/.osc/_apiurl create mode 100644 tests/project_package_status_fixtures/osctest/conflict/.osc/_files create mode 100644 tests/project_package_status_fixtures/osctest/conflict/.osc/_in_conflict create mode 100644 tests/project_package_status_fixtures/osctest/conflict/.osc/_osclib_version create mode 100644 tests/project_package_status_fixtures/osctest/conflict/.osc/_package create mode 100644 tests/project_package_status_fixtures/osctest/conflict/.osc/_project create mode 100644 tests/project_package_status_fixtures/osctest/conflict/.osc/conflict create mode 100644 tests/project_package_status_fixtures/osctest/conflict/.osc/test create mode 100644 tests/project_package_status_fixtures/osctest/conflict/conflict create mode 100644 tests/project_package_status_fixtures/osctest/conflict/exists create mode 100644 tests/project_package_status_fixtures/osctest/conflict/test create mode 100644 tests/project_package_status_fixtures/osctest/deleted/.osc/_apiurl create mode 100644 tests/project_package_status_fixtures/osctest/deleted/.osc/_files create mode 100644 tests/project_package_status_fixtures/osctest/deleted/.osc/_osclib_version create mode 100644 tests/project_package_status_fixtures/osctest/deleted/.osc/_package create mode 100644 tests/project_package_status_fixtures/osctest/deleted/.osc/_project create mode 100644 tests/project_package_status_fixtures/osctest/deleted/.osc/_to_be_deleted create mode 100644 tests/project_package_status_fixtures/osctest/deleted/.osc/modified create mode 100644 tests/project_package_status_fixtures/osctest/deleted/.osc/test create mode 100644 tests/project_package_status_fixtures/osctest/excluded/.osc/_apiurl create mode 100644 tests/project_package_status_fixtures/osctest/excluded/.osc/_files create mode 100644 tests/project_package_status_fixtures/osctest/excluded/.osc/_osclib_version create mode 100644 tests/project_package_status_fixtures/osctest/excluded/.osc/_package create mode 100644 tests/project_package_status_fixtures/osctest/excluded/.osc/_project create mode 100644 tests/project_package_status_fixtures/osctest/excluded/.osc/modified create mode 100644 tests/project_package_status_fixtures/osctest/excluded/.osc/test create mode 100644 tests/project_package_status_fixtures/osctest/excluded/_linkerror create mode 100644 tests/project_package_status_fixtures/osctest/excluded/dir/file create mode 100644 tests/project_package_status_fixtures/osctest/excluded/exists create mode 100644 tests/project_package_status_fixtures/osctest/excluded/foo.orig create mode 100644 tests/project_package_status_fixtures/osctest/excluded/modified create mode 100644 tests/project_package_status_fixtures/osctest/excluded/test create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/_apiurl create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/_files create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/_osclib_version create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/_package create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/_project create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/_to_be_added create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/_to_be_deleted create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/foo create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/merge create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/missing create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/nochange create mode 100644 tests/project_package_status_fixtures/osctest/simple/.osc/test create mode 100644 tests/project_package_status_fixtures/osctest/simple/add create mode 100644 tests/project_package_status_fixtures/osctest/simple/exists create mode 100644 tests/project_package_status_fixtures/osctest/simple/missing create mode 100644 tests/project_package_status_fixtures/osctest/simple/nochange create mode 100644 tests/project_package_status_fixtures/osctest/simple/test create mode 100644 tests/test_package_status.py create mode 100644 tests/test_project_status.py diff --git a/tests/project_package_status_fixtures/oscrc b/tests/project_package_status_fixtures/oscrc new file mode 100644 index 00000000..04b2b0ab --- /dev/null +++ b/tests/project_package_status_fixtures/oscrc @@ -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 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 diff --git a/tests/project_package_status_fixtures/osctest/.osc/_apiurl b/tests/project_package_status_fixtures/osctest/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/project_package_status_fixtures/osctest/.osc/_packages b/tests/project_package_status_fixtures/osctest/.osc/_packages new file mode 100644 index 00000000..2b174fd6 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/.osc/_packages @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/project_package_status_fixtures/osctest/.osc/_project b/tests/project_package_status_fixtures/osctest/.osc/_project new file mode 100644 index 00000000..b83ffd3c --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/.osc/_project @@ -0,0 +1 @@ +osctest diff --git a/tests/project_package_status_fixtures/osctest/added/.osc/_apiurl b/tests/project_package_status_fixtures/osctest/added/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/added/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/project_package_status_fixtures/osctest/added/.osc/_files b/tests/project_package_status_fixtures/osctest/added/.osc/_files new file mode 100644 index 00000000..98141218 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/added/.osc/_files @@ -0,0 +1 @@ + diff --git a/tests/project_package_status_fixtures/osctest/added/.osc/_osclib_version b/tests/project_package_status_fixtures/osctest/added/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/added/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/project_package_status_fixtures/osctest/added/.osc/_package b/tests/project_package_status_fixtures/osctest/added/.osc/_package new file mode 100644 index 00000000..d5f7fc3f --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/added/.osc/_package @@ -0,0 +1 @@ +added diff --git a/tests/project_package_status_fixtures/osctest/added/.osc/_project b/tests/project_package_status_fixtures/osctest/added/.osc/_project new file mode 100644 index 00000000..b83ffd3c --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/added/.osc/_project @@ -0,0 +1 @@ +osctest diff --git a/tests/project_package_status_fixtures/osctest/added/.osc/_to_be_added b/tests/project_package_status_fixtures/osctest/added/.osc/_to_be_added new file mode 100644 index 00000000..3e757656 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/added/.osc/_to_be_added @@ -0,0 +1 @@ +new diff --git a/tests/project_package_status_fixtures/osctest/added/exists b/tests/project_package_status_fixtures/osctest/added/exists new file mode 100644 index 00000000..e69de29b diff --git a/tests/project_package_status_fixtures/osctest/added/new b/tests/project_package_status_fixtures/osctest/added/new new file mode 100644 index 00000000..3e757656 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/added/new @@ -0,0 +1 @@ +new diff --git a/tests/project_package_status_fixtures/osctest/conflict/.osc/_apiurl b/tests/project_package_status_fixtures/osctest/conflict/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/project_package_status_fixtures/osctest/conflict/.osc/_files b/tests/project_package_status_fixtures/osctest/conflict/.osc/_files new file mode 100644 index 00000000..141eaef8 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/.osc/_files @@ -0,0 +1,4 @@ + + + + diff --git a/tests/project_package_status_fixtures/osctest/conflict/.osc/_in_conflict b/tests/project_package_status_fixtures/osctest/conflict/.osc/_in_conflict new file mode 100644 index 00000000..9b1719f5 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/.osc/_in_conflict @@ -0,0 +1 @@ +conflict diff --git a/tests/project_package_status_fixtures/osctest/conflict/.osc/_osclib_version b/tests/project_package_status_fixtures/osctest/conflict/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/project_package_status_fixtures/osctest/conflict/.osc/_package b/tests/project_package_status_fixtures/osctest/conflict/.osc/_package new file mode 100644 index 00000000..9b1719f5 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/.osc/_package @@ -0,0 +1 @@ +conflict diff --git a/tests/project_package_status_fixtures/osctest/conflict/.osc/_project b/tests/project_package_status_fixtures/osctest/conflict/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/project_package_status_fixtures/osctest/conflict/.osc/conflict b/tests/project_package_status_fixtures/osctest/conflict/.osc/conflict new file mode 100644 index 00000000..34d68721 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/.osc/conflict @@ -0,0 +1 @@ +This file did change. diff --git a/tests/project_package_status_fixtures/osctest/conflict/.osc/test b/tests/project_package_status_fixtures/osctest/conflict/.osc/test new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/.osc/test @@ -0,0 +1 @@ +test diff --git a/tests/project_package_status_fixtures/osctest/conflict/conflict b/tests/project_package_status_fixtures/osctest/conflict/conflict new file mode 100644 index 00000000..e47c5a68 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/conflict @@ -0,0 +1 @@ +Inconflict diff --git a/tests/project_package_status_fixtures/osctest/conflict/exists b/tests/project_package_status_fixtures/osctest/conflict/exists new file mode 100644 index 00000000..e69de29b diff --git a/tests/project_package_status_fixtures/osctest/conflict/test b/tests/project_package_status_fixtures/osctest/conflict/test new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/conflict/test @@ -0,0 +1 @@ +test diff --git a/tests/project_package_status_fixtures/osctest/deleted/.osc/_apiurl b/tests/project_package_status_fixtures/osctest/deleted/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/deleted/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/project_package_status_fixtures/osctest/deleted/.osc/_files b/tests/project_package_status_fixtures/osctest/deleted/.osc/_files new file mode 100644 index 00000000..af92bf7e --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/deleted/.osc/_files @@ -0,0 +1,4 @@ + + + + diff --git a/tests/project_package_status_fixtures/osctest/deleted/.osc/_osclib_version b/tests/project_package_status_fixtures/osctest/deleted/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/deleted/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/project_package_status_fixtures/osctest/deleted/.osc/_package b/tests/project_package_status_fixtures/osctest/deleted/.osc/_package new file mode 100644 index 00000000..71779d2c --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/deleted/.osc/_package @@ -0,0 +1 @@ +deleted diff --git a/tests/project_package_status_fixtures/osctest/deleted/.osc/_project b/tests/project_package_status_fixtures/osctest/deleted/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/deleted/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/project_package_status_fixtures/osctest/deleted/.osc/_to_be_deleted b/tests/project_package_status_fixtures/osctest/deleted/.osc/_to_be_deleted new file mode 100644 index 00000000..25fff4f9 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/deleted/.osc/_to_be_deleted @@ -0,0 +1,2 @@ +modified +test diff --git a/tests/project_package_status_fixtures/osctest/deleted/.osc/modified b/tests/project_package_status_fixtures/osctest/deleted/.osc/modified new file mode 100644 index 00000000..34d68721 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/deleted/.osc/modified @@ -0,0 +1 @@ +This file did change. diff --git a/tests/project_package_status_fixtures/osctest/deleted/.osc/test b/tests/project_package_status_fixtures/osctest/deleted/.osc/test new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/deleted/.osc/test @@ -0,0 +1 @@ +test diff --git a/tests/project_package_status_fixtures/osctest/excluded/.osc/_apiurl b/tests/project_package_status_fixtures/osctest/excluded/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/project_package_status_fixtures/osctest/excluded/.osc/_files b/tests/project_package_status_fixtures/osctest/excluded/.osc/_files new file mode 100644 index 00000000..af92bf7e --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/.osc/_files @@ -0,0 +1,4 @@ + + + + diff --git a/tests/project_package_status_fixtures/osctest/excluded/.osc/_osclib_version b/tests/project_package_status_fixtures/osctest/excluded/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/project_package_status_fixtures/osctest/excluded/.osc/_package b/tests/project_package_status_fixtures/osctest/excluded/.osc/_package new file mode 100644 index 00000000..bbde3dc9 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/.osc/_package @@ -0,0 +1 @@ +excluded diff --git a/tests/project_package_status_fixtures/osctest/excluded/.osc/_project b/tests/project_package_status_fixtures/osctest/excluded/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/project_package_status_fixtures/osctest/excluded/.osc/modified b/tests/project_package_status_fixtures/osctest/excluded/.osc/modified new file mode 100644 index 00000000..34d68721 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/.osc/modified @@ -0,0 +1 @@ +This file did change. diff --git a/tests/project_package_status_fixtures/osctest/excluded/.osc/test b/tests/project_package_status_fixtures/osctest/excluded/.osc/test new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/.osc/test @@ -0,0 +1 @@ +test diff --git a/tests/project_package_status_fixtures/osctest/excluded/_linkerror b/tests/project_package_status_fixtures/osctest/excluded/_linkerror new file mode 100644 index 00000000..e69de29b diff --git a/tests/project_package_status_fixtures/osctest/excluded/dir/file b/tests/project_package_status_fixtures/osctest/excluded/dir/file new file mode 100644 index 00000000..f73f3093 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/dir/file @@ -0,0 +1 @@ +file diff --git a/tests/project_package_status_fixtures/osctest/excluded/exists b/tests/project_package_status_fixtures/osctest/excluded/exists new file mode 100644 index 00000000..e69de29b diff --git a/tests/project_package_status_fixtures/osctest/excluded/foo.orig b/tests/project_package_status_fixtures/osctest/excluded/foo.orig new file mode 100644 index 00000000..e69de29b diff --git a/tests/project_package_status_fixtures/osctest/excluded/modified b/tests/project_package_status_fixtures/osctest/excluded/modified new file mode 100644 index 00000000..2e099600 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/modified @@ -0,0 +1 @@ +modified diff --git a/tests/project_package_status_fixtures/osctest/excluded/test b/tests/project_package_status_fixtures/osctest/excluded/test new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/excluded/test @@ -0,0 +1 @@ +test diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/_apiurl b/tests/project_package_status_fixtures/osctest/simple/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/_files b/tests/project_package_status_fixtures/osctest/simple/.osc/_files new file mode 100644 index 00000000..01e60f4e --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/_files @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/_osclib_version b/tests/project_package_status_fixtures/osctest/simple/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/_package b/tests/project_package_status_fixtures/osctest/simple/.osc/_package new file mode 100644 index 00000000..ab234747 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/_package @@ -0,0 +1 @@ +simple diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/_project b/tests/project_package_status_fixtures/osctest/simple/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/_to_be_added b/tests/project_package_status_fixtures/osctest/simple/.osc/_to_be_added new file mode 100644 index 00000000..f4991438 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/_to_be_added @@ -0,0 +1,3 @@ +add +missing +missing_added diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/_to_be_deleted b/tests/project_package_status_fixtures/osctest/simple/.osc/_to_be_deleted new file mode 100644 index 00000000..257cc564 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/_to_be_deleted @@ -0,0 +1 @@ +foo diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/foo b/tests/project_package_status_fixtures/osctest/simple/.osc/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/merge b/tests/project_package_status_fixtures/osctest/simple/.osc/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/missing b/tests/project_package_status_fixtures/osctest/simple/.osc/missing new file mode 100644 index 00000000..33e45d56 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/missing @@ -0,0 +1 @@ +missing diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/nochange b/tests/project_package_status_fixtures/osctest/simple/.osc/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/project_package_status_fixtures/osctest/simple/.osc/test b/tests/project_package_status_fixtures/osctest/simple/.osc/test new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/.osc/test @@ -0,0 +1 @@ +test diff --git a/tests/project_package_status_fixtures/osctest/simple/add b/tests/project_package_status_fixtures/osctest/simple/add new file mode 100644 index 00000000..b242c360 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/add @@ -0,0 +1 @@ +added file diff --git a/tests/project_package_status_fixtures/osctest/simple/exists b/tests/project_package_status_fixtures/osctest/simple/exists new file mode 100644 index 00000000..e69de29b diff --git a/tests/project_package_status_fixtures/osctest/simple/missing b/tests/project_package_status_fixtures/osctest/simple/missing new file mode 100644 index 00000000..feae347d --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/missing @@ -0,0 +1 @@ +replaced diff --git a/tests/project_package_status_fixtures/osctest/simple/nochange b/tests/project_package_status_fixtures/osctest/simple/nochange new file mode 100644 index 00000000..34d68721 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/nochange @@ -0,0 +1 @@ +This file did change. diff --git a/tests/project_package_status_fixtures/osctest/simple/test b/tests/project_package_status_fixtures/osctest/simple/test new file mode 100644 index 00000000..9daeafb9 --- /dev/null +++ b/tests/project_package_status_fixtures/osctest/simple/test @@ -0,0 +1 @@ +test diff --git a/tests/suite.py b/tests/suite.py index 30492225..233eb41c 100644 --- a/tests/suite.py +++ b/tests/suite.py @@ -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()) diff --git a/tests/test_package_status.py b/tests/test_package_status.py new file mode 100644 index 00000000..430adec0 --- /dev/null +++ b/tests/test_package_status.py @@ -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() diff --git a/tests/test_project_status.py b/tests/test_project_status.py new file mode 100644 index 00000000..3c8497f5 --- /dev/null +++ b/tests/test_project_status.py @@ -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()