diff --git a/behave/features/createrequest.feature b/behave/features/createrequest.feature new file mode 100644 index 00000000..ee983966 --- /dev/null +++ b/behave/features/createrequest.feature @@ -0,0 +1,37 @@ +Feature: `osc createrequest` command + + +# common steps for all scenarios +Background: + Given I set working directory to "{context.osc.temp}" + And I execute osc with args "branch test:factory/test-pkgA" + # the package gets forked from the devel project! + And I execute osc with args "co home:Admin:branches:test:devel/test-pkgA" + And I set working directory to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA" + + +@destructive +Scenario: Run `osc createrequest` + When I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/new_file" + And I execute osc with args "add new_file" + And I execute osc with args "ci -m 'commit description'" + And I execute osc with args "createrequest -a submit -m 'request description'" + Then the exit code is 0 + + +@destructive +Scenario: Run `osc createrequest --supersede` + Given I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/new_file" + And I execute osc with args "add new_file" + And I execute osc with args "ci -m 'commit description'" + And I execute osc with args "createrequest -a submit -m 'request description'" + And the exit code is 0 + And I execute osc with args "api /request/1" + And stdout doesn't contain "" + When I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/another_file" + And I execute osc with args "add new_file" + And I execute osc with args "ci -m 'commit description'" + And I execute osc with args "createrequest -a submit -m 'request description' --supersede 1" + Then the exit code is 0 + And I execute osc with args "api /request/1" + And stdout contains "" diff --git a/behave/features/steps/common.py b/behave/features/steps/common.py index 04bc520d..03b42dd0 100644 --- a/behave/features/steps/common.py +++ b/behave/features/steps/common.py @@ -1,5 +1,6 @@ import errno import os +import re import shutil import subprocess @@ -86,14 +87,28 @@ def run_in_context(context, cmd, can_fail=False, **run_args): def step_impl(context, text): if re.search(text.format(context=context), context.cmd_stdout): return - raise AssertionError("Stdout doesn't contain: %s" % text) + raise AssertionError("Stdout doesn't contain expected pattern: %s" % text) + + +@behave.step("stdout doesn't contain \"{text}\"") +def step_impl(context, text): + if not re.search(text.format(context=context), context.cmd_stdout): + return + raise AssertionError("Stdout is not supposed to contain pattern: %s" % text) @behave.step("stderr contains \"{text}\"") def step_impl(context, text): if re.search(text.format(context=context), context.cmd_stderr): return - raise AssertionError("Stderr doesn't contain: %s" % text) + raise AssertionError("Stderr doesn't contain expected pattern: %s" % text) + + +@behave.step("stderr doesn't contain \"{text}\"") +def step_impl(context, text): + if not re.search(text.format(context=context), context.cmd_stderr): + return + raise AssertionError("Stderr is not supposed to contain pattern: %s" % text) @behave.step("stdout is") diff --git a/behave/features/submitrequest.feature b/behave/features/submitrequest.feature new file mode 100644 index 00000000..907757e3 --- /dev/null +++ b/behave/features/submitrequest.feature @@ -0,0 +1,37 @@ +Feature: `osc submitrequest` command + + +# common steps for all scenarios +Background: + Given I set working directory to "{context.osc.temp}" + And I execute osc with args "branch test:factory/test-pkgA" + # the package gets forked from the devel project! + And I execute osc with args "co home:Admin:branches:test:devel/test-pkgA" + And I set working directory to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA" + + +@destructive +Scenario: Run `osc submitrequest` + When I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/new_file" + And I execute osc with args "add new_file" + And I execute osc with args "ci -m 'commit description'" + And I execute osc with args "submitrequest -m 'request description'" + Then the exit code is 0 + + +@destructive +Scenario: Run `osc submitrequest --supersede` + Given I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/new_file" + And I execute osc with args "add new_file" + And I execute osc with args "ci -m 'commit description'" + And I execute osc with args "submitrequest -m 'request description'" + And the exit code is 0 + And I execute osc with args "api /request/1" + And stdout doesn't contain "" + When I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/another_file" + And I execute osc with args "add new_file" + And I execute osc with args "ci -m 'commit description'" + And I execute osc with args "submitrequest -m 'request description' --supersede 1" + Then the exit code is 0 + And I execute osc with args "api /request/1" + And stdout contains ""