Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
99
Issues
99
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
55d1d817
Commit
55d1d817
authored
Feb 29, 2016
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide a better way to check stanzas at each step of the end_to_end test
parent
13eceeee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
tests/end_to_end/__main__.py
tests/end_to_end/__main__.py
+18
-7
No files found.
tests/end_to_end/__main__.py
View file @
55d1d817
...
...
@@ -16,6 +16,10 @@ class MatchAll(slixmpp.xmlstream.matcher.base.MatcherBase):
return
True
class
StanzaError
(
Exception
):
pass
class
XMPPComponent
(
slixmpp
.
BaseXMPP
):
"""
XMPPComponent sending a “scenario” of stanzas, checking that the responses
...
...
@@ -41,7 +45,9 @@ class XMPPComponent(slixmpp.BaseXMPP):
self
.
scenario
=
scenario
self
.
biboumi
=
biboumi
self
.
expected_xpath
=
None
# A callable, taking a stanza as argument and raising a StanzaError
# exception if the test should fail.
self
.
stanza_checker
=
None
self
.
failed
=
False
self
.
accepting_server
=
None
...
...
@@ -54,11 +60,12 @@ class XMPPComponent(slixmpp.BaseXMPP):
self
.
loop
.
stop
()
def
handle_incoming_stanza
(
self
,
stanza
):
if
self
.
expected_xpath
:
matched
=
slixmpp
.
xmlstream
.
matcher
.
xpath
.
MatchXPath
(
self
.
expected_xpath
).
match
(
stanza
)
if
not
matched
:
self
.
error
(
"Received stanza “%s” did not match expected xpath “%s”"
%
(
stanza
,
self
.
expected_xpath
))
self
.
expected_xpath
=
None
if
self
.
stanza_checker
:
try
:
self
.
stanza_checker
(
stanza
)
except
StanzaError
as
e
:
self
.
error
(
e
)
self
.
stanza_checker
=
None
self
.
run_scenario
()
def
run_scenario
(
self
):
...
...
@@ -73,6 +80,10 @@ class XMPPComponent(slixmpp.BaseXMPP):
self
.
accepting_server
=
yield
from
self
.
loop
.
create_server
(
lambda
:
self
,
"127.0.0.1"
,
"8811"
,
reuse_address
=
True
)
def
check_xpath
(
xpath
,
stanza
):
matched
=
slixmpp
.
xmlstream
.
matcher
.
xpath
.
MatchXPath
(
xpath
).
match
(
stanza
)
if
not
matched
:
raise
StanzaError
(
"Received stanza “%s” did not match expected xpath “%s”"
%
(
stanza
,
self
.
expected_xpath
))
class
Scenario
:
"""Defines a list of actions that are executed in sequence, until one of
...
...
@@ -127,7 +138,7 @@ def send_stanza(stanza, xmpp, biboumi):
def
expect_stanza
(
xpath
,
xmpp
,
biboumi
):
xmpp
.
expected_xpath
=
xpath
xmpp
.
stanza_checker
=
partial
(
check_xpath
,
xpath
)
class
BiboumiTest
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment