From 9c2f1d85ca409ec7d293cdae4e31a56c14d51b49 Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Mon, 30 Aug 2010 18:32:05 +0200 Subject: [PATCH] - added testcase for the "def commit" method + _missing_ log message from a5a0917fce7124f9cc8458a9ee41ced521aa502e missing log for a5a0917fce7124f9cc8458a9ee41ced521aa502e: - added support for @POST, @PUT, @DELETE decorators - support optional "exception" keyword arg for the decorators (the specified exception will be raised before returning the response) - moved "_check_digests" into the common module --- tests/commit_fixtures/oscrc | 104 +++++++++++ tests/commit_fixtures/osctest/.osc/_apiurl | 1 + tests/commit_fixtures/osctest/.osc/_packages | 1 + tests/commit_fixtures/osctest/.osc/_project | 1 + .../commit_fixtures/osctest/add/.osc/_apiurl | 1 + tests/commit_fixtures/osctest/add/.osc/_files | 5 + .../osctest/add/.osc/_osclib_version | 1 + .../commit_fixtures/osctest/add/.osc/_package | 1 + .../commit_fixtures/osctest/add/.osc/_project | 1 + .../osctest/add/.osc/_to_be_added | 1 + tests/commit_fixtures/osctest/add/.osc/foo | 1 + tests/commit_fixtures/osctest/add/.osc/merge | 4 + .../commit_fixtures/osctest/add/.osc/nochange | 1 + tests/commit_fixtures/osctest/add/add | 1 + tests/commit_fixtures/osctest/add/exists | 0 tests/commit_fixtures/osctest/add/foo | 1 + tests/commit_fixtures/osctest/add/merge | 4 + tests/commit_fixtures/osctest/add/nochange | 1 + .../osctest/conflict/.osc/_apiurl | 1 + .../osctest/conflict/.osc/_files | 5 + .../osctest/conflict/.osc/_in_conflict | 1 + .../osctest/conflict/.osc/_osclib_version | 1 + .../osctest/conflict/.osc/_package | 1 + .../osctest/conflict/.osc/_project | 1 + .../commit_fixtures/osctest/conflict/.osc/foo | 1 + .../osctest/conflict/.osc/merge | 4 + .../osctest/conflict/.osc/nochange | 1 + tests/commit_fixtures/osctest/conflict/foo | 1 + tests/commit_fixtures/osctest/conflict/merge | 4 + .../commit_fixtures/osctest/conflict/nochange | 1 + .../osctest/delete/.osc/_apiurl | 1 + .../osctest/delete/.osc/_files | 5 + .../osctest/delete/.osc/_osclib_version | 1 + .../osctest/delete/.osc/_package | 1 + .../osctest/delete/.osc/_project | 1 + .../osctest/delete/.osc/_to_be_deleted | 1 + tests/commit_fixtures/osctest/delete/.osc/foo | 1 + .../commit_fixtures/osctest/delete/.osc/merge | 4 + .../osctest/delete/.osc/nochange | 1 + tests/commit_fixtures/osctest/delete/exists | 0 tests/commit_fixtures/osctest/delete/foo | 1 + tests/commit_fixtures/osctest/delete/merge | 4 + .../osctest/multiple/.osc/_apiurl | 1 + .../osctest/multiple/.osc/_files | 5 + .../osctest/multiple/.osc/_osclib_version | 1 + .../osctest/multiple/.osc/_package | 1 + .../osctest/multiple/.osc/_project | 1 + .../osctest/multiple/.osc/_to_be_added | 2 + .../osctest/multiple/.osc/_to_be_deleted | 2 + .../commit_fixtures/osctest/multiple/.osc/foo | 1 + .../osctest/multiple/.osc/merge | 4 + .../osctest/multiple/.osc/nochange | 1 + tests/commit_fixtures/osctest/multiple/add | 1 + tests/commit_fixtures/osctest/multiple/add2 | 1 + tests/commit_fixtures/osctest/multiple/exists | 0 .../commit_fixtures/osctest/multiple/nochange | 1 + .../osctest/nochanges/.osc/_apiurl | 1 + .../osctest/nochanges/.osc/_files | 5 + .../osctest/nochanges/.osc/_osclib_version | 1 + .../osctest/nochanges/.osc/_package | 1 + .../osctest/nochanges/.osc/_project | 1 + .../osctest/nochanges/.osc/foo | 1 + .../osctest/nochanges/.osc/merge | 4 + .../osctest/nochanges/.osc/nochange | 1 + .../commit_fixtures/osctest/nochanges/exists | 0 .../osctest/nochanges/nochange | 1 + .../osctest/simple/.osc/_apiurl | 1 + .../osctest/simple/.osc/_files | 5 + .../osctest/simple/.osc/_osclib_version | 1 + .../osctest/simple/.osc/_package | 1 + .../osctest/simple/.osc/_project | 1 + tests/commit_fixtures/osctest/simple/.osc/foo | 1 + .../commit_fixtures/osctest/simple/.osc/merge | 4 + .../osctest/simple/.osc/nochange | 1 + tests/commit_fixtures/osctest/simple/exists | 0 tests/commit_fixtures/osctest/simple/foo | 1 + tests/commit_fixtures/osctest/simple/merge | 4 + tests/commit_fixtures/osctest/simple/nochange | 2 + .../commit_fixtures/testAddfile_cfilesremote | 6 + tests/commit_fixtures/testAddfile_filesremote | 5 + .../testConflictfile_filesremote | 5 + .../testDeletefile_cfilesremote | 4 + .../testDeletefile_filesremote | 5 + .../commit_fixtures/testMultiple_cfilesremote | 5 + .../commit_fixtures/testMultiple_filesremote | 5 + .../commit_fixtures/testNoChanges_filesremote | 5 + .../commit_fixtures/testPartial_cfilesremote | 5 + tests/commit_fixtures/testPartial_filesremote | 5 + tests/commit_fixtures/testSimple_cfilesremote | 5 + tests/commit_fixtures/testSimple_filesremote | 5 + tests/test_commit.py | 163 ++++++++++++++++++ 91 files changed, 456 insertions(+) create mode 100644 tests/commit_fixtures/oscrc create mode 100644 tests/commit_fixtures/osctest/.osc/_apiurl create mode 100644 tests/commit_fixtures/osctest/.osc/_packages create mode 100644 tests/commit_fixtures/osctest/.osc/_project create mode 100644 tests/commit_fixtures/osctest/add/.osc/_apiurl create mode 100644 tests/commit_fixtures/osctest/add/.osc/_files create mode 100644 tests/commit_fixtures/osctest/add/.osc/_osclib_version create mode 100644 tests/commit_fixtures/osctest/add/.osc/_package create mode 100644 tests/commit_fixtures/osctest/add/.osc/_project create mode 100644 tests/commit_fixtures/osctest/add/.osc/_to_be_added create mode 100644 tests/commit_fixtures/osctest/add/.osc/foo create mode 100644 tests/commit_fixtures/osctest/add/.osc/merge create mode 100644 tests/commit_fixtures/osctest/add/.osc/nochange create mode 100644 tests/commit_fixtures/osctest/add/add create mode 100644 tests/commit_fixtures/osctest/add/exists create mode 100644 tests/commit_fixtures/osctest/add/foo create mode 100644 tests/commit_fixtures/osctest/add/merge create mode 100644 tests/commit_fixtures/osctest/add/nochange create mode 100644 tests/commit_fixtures/osctest/conflict/.osc/_apiurl create mode 100644 tests/commit_fixtures/osctest/conflict/.osc/_files create mode 100644 tests/commit_fixtures/osctest/conflict/.osc/_in_conflict create mode 100644 tests/commit_fixtures/osctest/conflict/.osc/_osclib_version create mode 100644 tests/commit_fixtures/osctest/conflict/.osc/_package create mode 100644 tests/commit_fixtures/osctest/conflict/.osc/_project create mode 100644 tests/commit_fixtures/osctest/conflict/.osc/foo create mode 100644 tests/commit_fixtures/osctest/conflict/.osc/merge create mode 100644 tests/commit_fixtures/osctest/conflict/.osc/nochange create mode 100644 tests/commit_fixtures/osctest/conflict/foo create mode 100644 tests/commit_fixtures/osctest/conflict/merge create mode 100644 tests/commit_fixtures/osctest/conflict/nochange create mode 100644 tests/commit_fixtures/osctest/delete/.osc/_apiurl create mode 100644 tests/commit_fixtures/osctest/delete/.osc/_files create mode 100644 tests/commit_fixtures/osctest/delete/.osc/_osclib_version create mode 100644 tests/commit_fixtures/osctest/delete/.osc/_package create mode 100644 tests/commit_fixtures/osctest/delete/.osc/_project create mode 100644 tests/commit_fixtures/osctest/delete/.osc/_to_be_deleted create mode 100644 tests/commit_fixtures/osctest/delete/.osc/foo create mode 100644 tests/commit_fixtures/osctest/delete/.osc/merge create mode 100644 tests/commit_fixtures/osctest/delete/.osc/nochange create mode 100644 tests/commit_fixtures/osctest/delete/exists create mode 100644 tests/commit_fixtures/osctest/delete/foo create mode 100644 tests/commit_fixtures/osctest/delete/merge create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/_apiurl create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/_files create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/_osclib_version create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/_package create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/_project create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/_to_be_added create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/_to_be_deleted create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/foo create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/merge create mode 100644 tests/commit_fixtures/osctest/multiple/.osc/nochange create mode 100644 tests/commit_fixtures/osctest/multiple/add create mode 100644 tests/commit_fixtures/osctest/multiple/add2 create mode 100644 tests/commit_fixtures/osctest/multiple/exists create mode 100644 tests/commit_fixtures/osctest/multiple/nochange create mode 100644 tests/commit_fixtures/osctest/nochanges/.osc/_apiurl create mode 100644 tests/commit_fixtures/osctest/nochanges/.osc/_files create mode 100644 tests/commit_fixtures/osctest/nochanges/.osc/_osclib_version create mode 100644 tests/commit_fixtures/osctest/nochanges/.osc/_package create mode 100644 tests/commit_fixtures/osctest/nochanges/.osc/_project create mode 100644 tests/commit_fixtures/osctest/nochanges/.osc/foo create mode 100644 tests/commit_fixtures/osctest/nochanges/.osc/merge create mode 100644 tests/commit_fixtures/osctest/nochanges/.osc/nochange create mode 100644 tests/commit_fixtures/osctest/nochanges/exists create mode 100644 tests/commit_fixtures/osctest/nochanges/nochange create mode 100644 tests/commit_fixtures/osctest/simple/.osc/_apiurl create mode 100644 tests/commit_fixtures/osctest/simple/.osc/_files create mode 100644 tests/commit_fixtures/osctest/simple/.osc/_osclib_version create mode 100644 tests/commit_fixtures/osctest/simple/.osc/_package create mode 100644 tests/commit_fixtures/osctest/simple/.osc/_project create mode 100644 tests/commit_fixtures/osctest/simple/.osc/foo create mode 100644 tests/commit_fixtures/osctest/simple/.osc/merge create mode 100644 tests/commit_fixtures/osctest/simple/.osc/nochange create mode 100644 tests/commit_fixtures/osctest/simple/exists create mode 100644 tests/commit_fixtures/osctest/simple/foo create mode 100644 tests/commit_fixtures/osctest/simple/merge create mode 100644 tests/commit_fixtures/osctest/simple/nochange create mode 100644 tests/commit_fixtures/testAddfile_cfilesremote create mode 100644 tests/commit_fixtures/testAddfile_filesremote create mode 100644 tests/commit_fixtures/testConflictfile_filesremote create mode 100644 tests/commit_fixtures/testDeletefile_cfilesremote create mode 100644 tests/commit_fixtures/testDeletefile_filesremote create mode 100644 tests/commit_fixtures/testMultiple_cfilesremote create mode 100644 tests/commit_fixtures/testMultiple_filesremote create mode 100644 tests/commit_fixtures/testNoChanges_filesremote create mode 100644 tests/commit_fixtures/testPartial_cfilesremote create mode 100644 tests/commit_fixtures/testPartial_filesremote create mode 100644 tests/commit_fixtures/testSimple_cfilesremote create mode 100644 tests/commit_fixtures/testSimple_filesremote create mode 100644 tests/test_commit.py diff --git a/tests/commit_fixtures/oscrc b/tests/commit_fixtures/oscrc new file mode 100644 index 00000000..04b2b0ab --- /dev/null +++ b/tests/commit_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/commit_fixtures/osctest/.osc/_apiurl b/tests/commit_fixtures/osctest/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/commit_fixtures/osctest/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/commit_fixtures/osctest/.osc/_packages b/tests/commit_fixtures/osctest/.osc/_packages new file mode 100644 index 00000000..04e56f00 --- /dev/null +++ b/tests/commit_fixtures/osctest/.osc/_packages @@ -0,0 +1 @@ + diff --git a/tests/commit_fixtures/osctest/.osc/_project b/tests/commit_fixtures/osctest/.osc/_project new file mode 100644 index 00000000..b83ffd3c --- /dev/null +++ b/tests/commit_fixtures/osctest/.osc/_project @@ -0,0 +1 @@ +osctest diff --git a/tests/commit_fixtures/osctest/add/.osc/_apiurl b/tests/commit_fixtures/osctest/add/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/commit_fixtures/osctest/add/.osc/_files b/tests/commit_fixtures/osctest/add/.osc/_files new file mode 100644 index 00000000..d2e3da5f --- /dev/null +++ b/tests/commit_fixtures/osctest/add/.osc/_files @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/osctest/add/.osc/_osclib_version b/tests/commit_fixtures/osctest/add/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/commit_fixtures/osctest/add/.osc/_package b/tests/commit_fixtures/osctest/add/.osc/_package new file mode 100644 index 00000000..76d4bb83 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/.osc/_package @@ -0,0 +1 @@ +add diff --git a/tests/commit_fixtures/osctest/add/.osc/_project b/tests/commit_fixtures/osctest/add/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/commit_fixtures/osctest/add/.osc/_to_be_added b/tests/commit_fixtures/osctest/add/.osc/_to_be_added new file mode 100644 index 00000000..76d4bb83 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/.osc/_to_be_added @@ -0,0 +1 @@ +add diff --git a/tests/commit_fixtures/osctest/add/.osc/foo b/tests/commit_fixtures/osctest/add/.osc/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/.osc/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/add/.osc/merge b/tests/commit_fixtures/osctest/add/.osc/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/.osc/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/add/.osc/nochange b/tests/commit_fixtures/osctest/add/.osc/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/commit_fixtures/osctest/add/.osc/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/commit_fixtures/osctest/add/add b/tests/commit_fixtures/osctest/add/add new file mode 100644 index 00000000..b242c360 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/add @@ -0,0 +1 @@ +added file diff --git a/tests/commit_fixtures/osctest/add/exists b/tests/commit_fixtures/osctest/add/exists new file mode 100644 index 00000000..e69de29b diff --git a/tests/commit_fixtures/osctest/add/foo b/tests/commit_fixtures/osctest/add/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/add/merge b/tests/commit_fixtures/osctest/add/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/commit_fixtures/osctest/add/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/add/nochange b/tests/commit_fixtures/osctest/add/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/commit_fixtures/osctest/add/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/commit_fixtures/osctest/conflict/.osc/_apiurl b/tests/commit_fixtures/osctest/conflict/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/commit_fixtures/osctest/conflict/.osc/_files b/tests/commit_fixtures/osctest/conflict/.osc/_files new file mode 100644 index 00000000..a67ff429 --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/.osc/_files @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/tests/commit_fixtures/osctest/conflict/.osc/_in_conflict b/tests/commit_fixtures/osctest/conflict/.osc/_in_conflict new file mode 100644 index 00000000..a00af07a --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/.osc/_in_conflict @@ -0,0 +1 @@ +merge diff --git a/tests/commit_fixtures/osctest/conflict/.osc/_osclib_version b/tests/commit_fixtures/osctest/conflict/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/commit_fixtures/osctest/conflict/.osc/_package b/tests/commit_fixtures/osctest/conflict/.osc/_package new file mode 100644 index 00000000..783a0ef7 --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/.osc/_package @@ -0,0 +1 @@ +conflict \ No newline at end of file diff --git a/tests/commit_fixtures/osctest/conflict/.osc/_project b/tests/commit_fixtures/osctest/conflict/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/commit_fixtures/osctest/conflict/.osc/foo b/tests/commit_fixtures/osctest/conflict/.osc/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/.osc/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/conflict/.osc/merge b/tests/commit_fixtures/osctest/conflict/.osc/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/.osc/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/conflict/.osc/nochange b/tests/commit_fixtures/osctest/conflict/.osc/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/.osc/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/commit_fixtures/osctest/conflict/foo b/tests/commit_fixtures/osctest/conflict/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/conflict/merge b/tests/commit_fixtures/osctest/conflict/merge new file mode 100644 index 00000000..f4ff1649 --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/merge @@ -0,0 +1,4 @@ +Is it possible +to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/conflict/nochange b/tests/commit_fixtures/osctest/conflict/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/commit_fixtures/osctest/conflict/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/commit_fixtures/osctest/delete/.osc/_apiurl b/tests/commit_fixtures/osctest/delete/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/commit_fixtures/osctest/delete/.osc/_files b/tests/commit_fixtures/osctest/delete/.osc/_files new file mode 100644 index 00000000..d2e3da5f --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/.osc/_files @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/osctest/delete/.osc/_osclib_version b/tests/commit_fixtures/osctest/delete/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/commit_fixtures/osctest/delete/.osc/_package b/tests/commit_fixtures/osctest/delete/.osc/_package new file mode 100644 index 00000000..c8b1b423 --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/.osc/_package @@ -0,0 +1 @@ +delete diff --git a/tests/commit_fixtures/osctest/delete/.osc/_project b/tests/commit_fixtures/osctest/delete/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/commit_fixtures/osctest/delete/.osc/_to_be_deleted b/tests/commit_fixtures/osctest/delete/.osc/_to_be_deleted new file mode 100644 index 00000000..55aa7469 --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/.osc/_to_be_deleted @@ -0,0 +1 @@ +nochange diff --git a/tests/commit_fixtures/osctest/delete/.osc/foo b/tests/commit_fixtures/osctest/delete/.osc/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/.osc/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/delete/.osc/merge b/tests/commit_fixtures/osctest/delete/.osc/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/.osc/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/delete/.osc/nochange b/tests/commit_fixtures/osctest/delete/.osc/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/.osc/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/commit_fixtures/osctest/delete/exists b/tests/commit_fixtures/osctest/delete/exists new file mode 100644 index 00000000..e69de29b diff --git a/tests/commit_fixtures/osctest/delete/foo b/tests/commit_fixtures/osctest/delete/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/delete/merge b/tests/commit_fixtures/osctest/delete/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/commit_fixtures/osctest/delete/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/multiple/.osc/_apiurl b/tests/commit_fixtures/osctest/multiple/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/commit_fixtures/osctest/multiple/.osc/_files b/tests/commit_fixtures/osctest/multiple/.osc/_files new file mode 100644 index 00000000..d2e3da5f --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/_files @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/osctest/multiple/.osc/_osclib_version b/tests/commit_fixtures/osctest/multiple/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/commit_fixtures/osctest/multiple/.osc/_package b/tests/commit_fixtures/osctest/multiple/.osc/_package new file mode 100644 index 00000000..5c4139db --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/_package @@ -0,0 +1 @@ +multiple diff --git a/tests/commit_fixtures/osctest/multiple/.osc/_project b/tests/commit_fixtures/osctest/multiple/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/commit_fixtures/osctest/multiple/.osc/_to_be_added b/tests/commit_fixtures/osctest/multiple/.osc/_to_be_added new file mode 100644 index 00000000..91e4e3df --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/_to_be_added @@ -0,0 +1,2 @@ +add +add2 diff --git a/tests/commit_fixtures/osctest/multiple/.osc/_to_be_deleted b/tests/commit_fixtures/osctest/multiple/.osc/_to_be_deleted new file mode 100644 index 00000000..cf978bc1 --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/_to_be_deleted @@ -0,0 +1,2 @@ +foo +merge diff --git a/tests/commit_fixtures/osctest/multiple/.osc/foo b/tests/commit_fixtures/osctest/multiple/.osc/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/multiple/.osc/merge b/tests/commit_fixtures/osctest/multiple/.osc/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/multiple/.osc/nochange b/tests/commit_fixtures/osctest/multiple/.osc/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/.osc/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/commit_fixtures/osctest/multiple/add b/tests/commit_fixtures/osctest/multiple/add new file mode 100644 index 00000000..b242c360 --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/add @@ -0,0 +1 @@ +added file diff --git a/tests/commit_fixtures/osctest/multiple/add2 b/tests/commit_fixtures/osctest/multiple/add2 new file mode 100644 index 00000000..47559038 --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/add2 @@ -0,0 +1 @@ +add2 diff --git a/tests/commit_fixtures/osctest/multiple/exists b/tests/commit_fixtures/osctest/multiple/exists new file mode 100644 index 00000000..e69de29b diff --git a/tests/commit_fixtures/osctest/multiple/nochange b/tests/commit_fixtures/osctest/multiple/nochange new file mode 100644 index 00000000..34d68721 --- /dev/null +++ b/tests/commit_fixtures/osctest/multiple/nochange @@ -0,0 +1 @@ +This file did change. diff --git a/tests/commit_fixtures/osctest/nochanges/.osc/_apiurl b/tests/commit_fixtures/osctest/nochanges/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/commit_fixtures/osctest/nochanges/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/commit_fixtures/osctest/nochanges/.osc/_files b/tests/commit_fixtures/osctest/nochanges/.osc/_files new file mode 100644 index 00000000..45f350aa --- /dev/null +++ b/tests/commit_fixtures/osctest/nochanges/.osc/_files @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/osctest/nochanges/.osc/_osclib_version b/tests/commit_fixtures/osctest/nochanges/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/commit_fixtures/osctest/nochanges/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/commit_fixtures/osctest/nochanges/.osc/_package b/tests/commit_fixtures/osctest/nochanges/.osc/_package new file mode 100644 index 00000000..40b16a98 --- /dev/null +++ b/tests/commit_fixtures/osctest/nochanges/.osc/_package @@ -0,0 +1 @@ +nochanges diff --git a/tests/commit_fixtures/osctest/nochanges/.osc/_project b/tests/commit_fixtures/osctest/nochanges/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/commit_fixtures/osctest/nochanges/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/commit_fixtures/osctest/nochanges/.osc/foo b/tests/commit_fixtures/osctest/nochanges/.osc/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/nochanges/.osc/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/nochanges/.osc/merge b/tests/commit_fixtures/osctest/nochanges/.osc/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/commit_fixtures/osctest/nochanges/.osc/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/nochanges/.osc/nochange b/tests/commit_fixtures/osctest/nochanges/.osc/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/commit_fixtures/osctest/nochanges/.osc/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/commit_fixtures/osctest/nochanges/exists b/tests/commit_fixtures/osctest/nochanges/exists new file mode 100644 index 00000000..e69de29b diff --git a/tests/commit_fixtures/osctest/nochanges/nochange b/tests/commit_fixtures/osctest/nochanges/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/commit_fixtures/osctest/nochanges/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/commit_fixtures/osctest/simple/.osc/_apiurl b/tests/commit_fixtures/osctest/simple/.osc/_apiurl new file mode 100644 index 00000000..0afeace7 --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/.osc/_apiurl @@ -0,0 +1 @@ +http://localhost diff --git a/tests/commit_fixtures/osctest/simple/.osc/_files b/tests/commit_fixtures/osctest/simple/.osc/_files new file mode 100644 index 00000000..d2e3da5f --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/.osc/_files @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/osctest/simple/.osc/_osclib_version b/tests/commit_fixtures/osctest/simple/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/commit_fixtures/osctest/simple/.osc/_package b/tests/commit_fixtures/osctest/simple/.osc/_package new file mode 100644 index 00000000..8fd32466 --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/.osc/_package @@ -0,0 +1 @@ +simple \ No newline at end of file diff --git a/tests/commit_fixtures/osctest/simple/.osc/_project b/tests/commit_fixtures/osctest/simple/.osc/_project new file mode 100644 index 00000000..cea3bc84 --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/.osc/_project @@ -0,0 +1 @@ +osctest \ No newline at end of file diff --git a/tests/commit_fixtures/osctest/simple/.osc/foo b/tests/commit_fixtures/osctest/simple/.osc/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/.osc/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/simple/.osc/merge b/tests/commit_fixtures/osctest/simple/.osc/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/.osc/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/simple/.osc/nochange b/tests/commit_fixtures/osctest/simple/.osc/nochange new file mode 100644 index 00000000..0569b03f --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/.osc/nochange @@ -0,0 +1 @@ +This file didn't change. diff --git a/tests/commit_fixtures/osctest/simple/exists b/tests/commit_fixtures/osctest/simple/exists new file mode 100644 index 00000000..e69de29b diff --git a/tests/commit_fixtures/osctest/simple/foo b/tests/commit_fixtures/osctest/simple/foo new file mode 100644 index 00000000..3bb34cf8 --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/foo @@ -0,0 +1 @@ +This is a simple test. diff --git a/tests/commit_fixtures/osctest/simple/merge b/tests/commit_fixtures/osctest/simple/merge new file mode 100644 index 00000000..0b4685d5 --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/merge @@ -0,0 +1,4 @@ +Is it +possible to +merge this file? +I hope so... diff --git a/tests/commit_fixtures/osctest/simple/nochange b/tests/commit_fixtures/osctest/simple/nochange new file mode 100644 index 00000000..3a48a293 --- /dev/null +++ b/tests/commit_fixtures/osctest/simple/nochange @@ -0,0 +1,2 @@ +This file didn't change but +is modified. diff --git a/tests/commit_fixtures/testAddfile_cfilesremote b/tests/commit_fixtures/testAddfile_cfilesremote new file mode 100644 index 00000000..47538b02 --- /dev/null +++ b/tests/commit_fixtures/testAddfile_cfilesremote @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/commit_fixtures/testAddfile_filesremote b/tests/commit_fixtures/testAddfile_filesremote new file mode 100644 index 00000000..d2e3da5f --- /dev/null +++ b/tests/commit_fixtures/testAddfile_filesremote @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/testConflictfile_filesremote b/tests/commit_fixtures/testConflictfile_filesremote new file mode 100644 index 00000000..a67ff429 --- /dev/null +++ b/tests/commit_fixtures/testConflictfile_filesremote @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/tests/commit_fixtures/testDeletefile_cfilesremote b/tests/commit_fixtures/testDeletefile_cfilesremote new file mode 100644 index 00000000..20ce708d --- /dev/null +++ b/tests/commit_fixtures/testDeletefile_cfilesremote @@ -0,0 +1,4 @@ + + + + diff --git a/tests/commit_fixtures/testDeletefile_filesremote b/tests/commit_fixtures/testDeletefile_filesremote new file mode 100644 index 00000000..d2e3da5f --- /dev/null +++ b/tests/commit_fixtures/testDeletefile_filesremote @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/testMultiple_cfilesremote b/tests/commit_fixtures/testMultiple_cfilesremote new file mode 100644 index 00000000..d399b74b --- /dev/null +++ b/tests/commit_fixtures/testMultiple_cfilesremote @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/testMultiple_filesremote b/tests/commit_fixtures/testMultiple_filesremote new file mode 100644 index 00000000..d2e3da5f --- /dev/null +++ b/tests/commit_fixtures/testMultiple_filesremote @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/testNoChanges_filesremote b/tests/commit_fixtures/testNoChanges_filesremote new file mode 100644 index 00000000..a67ff429 --- /dev/null +++ b/tests/commit_fixtures/testNoChanges_filesremote @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/tests/commit_fixtures/testPartial_cfilesremote b/tests/commit_fixtures/testPartial_cfilesremote new file mode 100644 index 00000000..dc410df8 --- /dev/null +++ b/tests/commit_fixtures/testPartial_cfilesremote @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/testPartial_filesremote b/tests/commit_fixtures/testPartial_filesremote new file mode 100644 index 00000000..d2e3da5f --- /dev/null +++ b/tests/commit_fixtures/testPartial_filesremote @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/testSimple_cfilesremote b/tests/commit_fixtures/testSimple_cfilesremote new file mode 100644 index 00000000..bc155b4e --- /dev/null +++ b/tests/commit_fixtures/testSimple_cfilesremote @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/commit_fixtures/testSimple_filesremote b/tests/commit_fixtures/testSimple_filesremote new file mode 100644 index 00000000..d2e3da5f --- /dev/null +++ b/tests/commit_fixtures/testSimple_filesremote @@ -0,0 +1,5 @@ + + + + + diff --git a/tests/test_commit.py b/tests/test_commit.py new file mode 100644 index 00000000..982ab03c --- /dev/null +++ b/tests/test_commit.py @@ -0,0 +1,163 @@ +import osc.core +import osc.oscerr +import os +import sys +from common import GET, PUT, POST, DELETE, OscTestCase +from xml.etree import cElementTree as ET +FIXTURES_DIR = os.path.join(os.getcwd(), 'commit_fixtures') + +def suite(): + import unittest + return unittest.makeSuite(TestCommit) + +rev_dummy = '\n ffffffffffffffffffffffffffffffff\n' + +class TestCommit(OscTestCase): + def _get_fixtures_dir(self): + return FIXTURES_DIR + + @GET('http://localhost/source/osctest/simple?rev=latest', file='testSimple_filesremote') + @PUT('http://localhost/source/osctest/simple/nochange?rev=upload', + exp='This file didn\'t change but\nis modified.\n', text=rev_dummy) + @POST('http://localhost/source/osctest/simple?comment=&cmd=commit&rev=upload&user=Admin', text='', + exp='') + @GET('http://localhost/source/osctest/simple?rev=2', file='testSimple_cfilesremote') + def test_simple(self): + """a simple commit (only one modified file)""" + self._change_to_pkg('simple') + p = osc.core.Package('.') + p.commit() + exp = 'Sending nochange\nTransmitting file data .\nCommitted revision 2.\n' + self.assertEqual(sys.stdout.getvalue(), exp) + self._check_digests('testSimple_cfilesremote') + self.assertTrue(os.path.exists('nochange')) + self.assertEqual(open('nochange', 'r').read(), open(os.path.join('.osc', 'nochange'), 'r').read()) + self._check_status(p, 'nochange', ' ') + + @GET('http://localhost/source/osctest/add?rev=latest', file='testAddfile_filesremote') + @PUT('http://localhost/source/osctest/add/add?rev=upload', + exp='added file\n', text=rev_dummy) + @POST('http://localhost/source/osctest/add?comment=&cmd=commit&rev=upload&user=Admin', text='', + exp='') + @GET('http://localhost/source/osctest/add?rev=2', file='testAddfile_cfilesremote') + def test_addfile(self): + """commit a new file""" + self._change_to_pkg('add') + p = osc.core.Package('.') + p.commit() + exp = 'Sending add\nTransmitting file data .\nCommitted revision 2.\n' + self.assertEqual(sys.stdout.getvalue(), exp) + self._check_digests('testAddfile_cfilesremote') + self.assertTrue(os.path.exists('add')) + self.assertEqual(open('add', 'r').read(), open(os.path.join('.osc', 'add'), 'r').read()) + self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added'))) + self._check_status(p, 'add', ' ') + + @GET('http://localhost/source/osctest/delete?rev=latest', file='testDeletefile_filesremote') + @DELETE('http://localhost/source/osctest/delete/nochange?rev=upload', text='') + @POST('http://localhost/source/osctest/delete?comment=&cmd=commit&rev=upload&user=Admin', text='', + exp='') + @GET('http://localhost/source/osctest/delete?rev=2', file='testDeletefile_cfilesremote') + def test_deletefile(self): + """delete a file""" + self._change_to_pkg('delete') + osc.core.Package('.').commit() + exp = 'Deleting nochange\nTransmitting file data \nCommitted revision 2.\n' + self.assertEqual(sys.stdout.getvalue(), exp) + self._check_digests('testDeletefile_cfilesremote') + self.assertFalse(os.path.exists('nochange')) + self.assertFalse(os.path.exists(os.path.join('.osc', 'nochange'))) + self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_deleted'))) + + @GET('http://localhost/source/osctest/conflict?rev=latest', file='testConflictfile_filesremote') + def test_conflictfile(self): + """package has a file which is in conflict state""" + self._change_to_pkg('conflict') + ret = osc.core.Package('.').commit() + self.assertTrue(ret == 1) + exp = 'Please resolve all conflicts before committing using "osc resolved FILE"!\n' + self.assertEqual(sys.stdout.getvalue(), exp) + self._check_digests('testConflictfile_filesremote') + self._check_conflictlist('merge\n') + + @GET('http://localhost/source/osctest/nochanges?rev=latest', file='testNoChanges_filesremote') + def test_nochanges(self): + """package has no changes (which can be committed)""" + self._change_to_pkg('nochanges') + ret = osc.core.Package('.').commit() + self.assertTrue(ret == 1) + exp = 'nothing to do for package nochanges\n' + self.assertEqual(sys.stdout.getvalue(), exp) + + @GET('http://localhost/source/osctest/multiple?rev=latest', file='testMultiple_filesremote') + @DELETE('http://localhost/source/osctest/multiple/foo?rev=upload', text='') + @DELETE('http://localhost/source/osctest/multiple/merge?rev=upload', text='') + @PUT('http://localhost/source/osctest/multiple/add?rev=upload', exp='added file\n', text=rev_dummy) + @PUT('http://localhost/source/osctest/multiple/add2?rev=upload', exp='add2\n', text=rev_dummy) + @PUT('http://localhost/source/osctest/multiple/nochange?rev=upload', exp='This file did change.\n', text=rev_dummy) + @POST('http://localhost/source/osctest/multiple?comment=&cmd=commit&rev=upload&user=Admin', text='', + exp='') + @GET('http://localhost/source/osctest/multiple?rev=2', file='testMultiple_cfilesremote') + def test_multiple(self): + """a simple commit (only one modified file)""" + self._change_to_pkg('multiple') + p = osc.core.Package('.') + p.commit() + exp = 'Sending add\nSending add2\nDeleting foo\nDeleting ' \ + 'merge\nSending nochange\nTransmitting file data ...\nCommitted revision 2.\n' + self.assertEqual(sys.stdout.getvalue(), exp) + self._check_digests('testMultiple_cfilesremote') + self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added'))) + self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_deleted'))) + self.assertFalse(os.path.exists(os.path.join('.osc', 'foo'))) + self.assertFalse(os.path.exists(os.path.join('.osc', 'merge'))) + self.assertRaises(IOError, p.status, 'foo') + self.assertRaises(IOError, p.status, 'merge') + self._check_status(p, 'add', ' ') + self._check_status(p, 'add2', ' ') + self._check_status(p, 'nochange', ' ') + + @GET('http://localhost/source/osctest/multiple?rev=latest', file='testPartial_filesremote') + @DELETE('http://localhost/source/osctest/multiple/foo?rev=upload', text='') + @PUT('http://localhost/source/osctest/multiple/add?rev=upload', exp='added file\n', text=rev_dummy) + @PUT('http://localhost/source/osctest/multiple/nochange?rev=upload', exp='This file did change.\n', text=rev_dummy) + @POST('http://localhost/source/osctest/multiple?comment=&cmd=commit&rev=upload&user=Admin', text='', + exp='') + @GET('http://localhost/source/osctest/multiple?rev=2', file='testPartial_cfilesremote') + def test_partial(self): + """commit only some files""" + self._change_to_pkg('multiple') + p = osc.core.Package('.') + p.todo = ['foo', 'add', 'nochange'] + p.commit() + exp = 'Sending add\nDeleting foo\n' \ + 'Sending nochange\nTransmitting file data ...\nCommitted revision 2.\n' + self.assertTrue(sys.stdout.getvalue(), exp) + self._check_digests('testPartial_cfilesremote') + self._check_addlist('add2\n') + self._check_deletelist('merge\n') + self._check_status(p, 'add2', 'A') + self._check_status(p, 'merge', 'D') + self._check_status(p, 'add', ' ') + self._check_status(p, 'nochange', ' ') + self.assertRaises(IOError, p.status, 'foo') + + @GET('http://localhost/source/osctest/simple?rev=latest', file='testSimple_filesremote') + @PUT('http://localhost/source/osctest/simple/nochange?rev=upload', exp='This file didn\'t change but\nis modified.\n', + exception=IOError('test exception'), text=rev_dummy) + @POST('http://localhost/source/osctest/simple?comment=&cmd=deleteuploadrev&rev=upload&user=Admin', text='', + exp='') + def test_interrupt(self): + """interrupt a commit""" + self._change_to_pkg('simple') + p = osc.core.Package('.') + self.assertRaises(IOError, p.commit) + exp = 'Sending nochange\nTransmitting file data .' + self.assertEqual(sys.stdout.getvalue(), exp) + self._check_digests('testSimple_filesremote') + self.assertTrue(os.path.exists('nochange')) + self._check_status(p, 'nochange', 'M') + +if __name__ == '__main__': + import unittest + unittest.main()