Skip to content

Commit

Permalink
feat(history): test added
Browse files Browse the repository at this point in the history
  • Loading branch information
edcuba committed Feb 14, 2017
1 parent 10a8801 commit 980ad00
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
72 changes: 72 additions & 0 deletions dnf-docker-test/features/history-1.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Feature: DNF/Behave test Transaction history - base

Scenario: Simple transaction
Given I use the repository "test-1"
When I execute "dnf" command "install -y TestA" with "success"
Then transaction changes are as follows
| State | Packages |
| installed | TestA, TestB |
When I execute "dnf" command "history" with "success"
Then the history should contain command "install -y TestA" and action "Install" with "2" packages

Scenario: Undo last transaction
Given I use the repository "test-1"
When I execute "dnf" command "history undo last -y" with "success"
Then transaction changes are as follows
| State | Packages |
| removed | TestA, TestB |
When I execute "dnf" command "history" with "success"
Then the history should contain command "history undo last -y" and action "Erase" with "2" packages

Scenario: Undo transaction last 2
Given I use the repository "test-1"
When I execute "dnf" command "history undo last -y" with "success"
Then transaction changes are as follows
| State | Packages |
| installed | TestA, TestB |
When I execute "dnf" command "history" with "success"
Then the history should contain command "history undo last -y" and action "Install" with "2" packages

Scenario: Undo transaction last-2
Given I use the repository "test-1"
When I execute "dnf" command "history undo last-2 -y" with "success"
Then transaction changes are as follows
| State | Packages |
| removed | TestA, TestB |
When I execute "dnf" command "history" with "success"
Then the history should contain command "history undo last-2 -y" and action "Erase" with "2" packages

Scenario: Redo transaction last
Given I use the repository "test-1"
When I execute "dnf" command "install -y TestA" with "success"
Then transaction changes are as follows
| State | Packages |
| installed | TestA, TestB |
When I execute "dnf" command "remove -y TestA" with "success"
Then transaction changes are as follows
| State | Packages |
| removed | TestA, TestB |
When I execute "dnf" command "history redo last-1 -y" with "success"
Then transaction changes are as follows
| State | Packages |
| installed | TestA, TestB |
When I execute "dnf" command "history" with "success"
Then the history should contain command "history redo last-1 -y" and action "Install" with "2" packages
When I execute "dnf" command "history redo last-1 -y" with "success"
Then transaction changes are as follows
| State | Packages |
| removed | TestA, TestB |
When I execute "dnf" command "history" with "success"
Then the history should contain command "history redo last-1 -y" and action "Remove" with "2" packages

Scenario: Update packages
Given I use the repository "test-1"
When I execute "dnf" command "install -y TestA TestD TestH" with "success"
Given I use the repository "upgrade_1"
When I execute "dnf" command "update -y" with "success"
Then transaction changes are as follows
| State | Packages |
| installed | TestD, TestE, TestA, TestB, TestH |
| removed | TestA, TestB, TestD, TestE, TestH |
When I execute "dnf" command "history" with "success"
Then the history should contain command "update -y" and action "Update" with "5" package
21 changes: 21 additions & 0 deletions dnf-docker-test/features/steps/history_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from behave import then
from behave import when
from behave import given

@then('the history should contain command "{cmdline}" and action "{action}" with "{altered}" package')
@then('the history should contain command "{cmdline}" and action "{action}" with "{altered}" packages')
def then_history_is(context, cmdline, action, altered):
lines = context.cmd_output.split('\n')
assert len(lines) > 3, 'No output'
del lines[:3]
match = False
for line in lines:
columns = line.split('|')
words = [word.strip() for word in columns]
# last member can be e.g. "1 >"
words += words[-1].split()
if set([cmdline, action, altered]).issubset(set(words)):
match = True
break
assert match, '''Command "{}" and action "{}" with "{}" packages not matched!
{}'''.format(cmdline, action, altered, context.cmd_output)

0 comments on commit 980ad00

Please sign in to comment.