Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
c2b190c8
Commit
c2b190c8
authored
Jun 02, 2016
by
Enrico Zini
Browse files
Slight refactoring of ExpectedSets
parent
aee6ab44
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
backend/unittest.py
View file @
c2b190c8
...
@@ -314,8 +314,9 @@ class ExpectedSets(defaultdict):
...
@@ -314,8 +314,9 @@ class ExpectedSets(defaultdict):
"""
"""
Store the permissions expected out of a *VisitorPermissions object
Store the permissions expected out of a *VisitorPermissions object
"""
"""
def
__init__
(
self
,
action_msg
=
"{visitor}"
,
issue_msg
=
"{problem} {mismatch}"
):
def
__init__
(
self
,
testcase
,
action_msg
=
"{visitor}"
,
issue_msg
=
"{problem} {mismatch}"
):
super
(
ExpectedSets
,
self
).
__init__
(
TestSet
)
super
(
ExpectedSets
,
self
).
__init__
(
TestSet
)
self
.
testcase
=
testcase
self
.
action_msg
=
action_msg
self
.
action_msg
=
action_msg
self
.
issue_msg
=
issue_msg
self
.
issue_msg
=
issue_msg
...
@@ -338,14 +339,14 @@ class ExpectedSets(defaultdict):
...
@@ -338,14 +339,14 @@ class ExpectedSets(defaultdict):
return
other_visitors
return
other_visitors
def
combine
(
self
,
other
):
def
combine
(
self
,
other
):
res
=
ExpectedSets
(
action_msg
=
self
.
action_msg
,
issue_msg
=
self
.
issue_msg
)
res
=
ExpectedSets
(
self
.
testcase
,
action_msg
=
self
.
action_msg
,
issue_msg
=
self
.
issue_msg
)
for
k
,
v
in
self
.
items
():
for
k
,
v
in
self
.
items
():
res
[
k
]
=
v
.
clone
()
res
[
k
]
=
v
.
clone
()
for
k
,
v
in
other
.
items
():
for
k
,
v
in
other
.
items
():
res
[
k
].
update
(
v
)
res
[
k
].
update
(
v
)
return
res
return
res
def
assertEqual
(
self
,
testcase
,
visitor
,
got
):
def
assertEqual
(
self
,
visitor
,
got
):
got
=
set
(
got
)
got
=
set
(
got
)
wanted
=
self
.
get
(
visitor
,
set
())
wanted
=
self
.
get
(
visitor
,
set
())
if
got
==
wanted
:
return
if
got
==
wanted
:
return
...
@@ -354,12 +355,12 @@ class ExpectedSets(defaultdict):
...
@@ -354,12 +355,12 @@ class ExpectedSets(defaultdict):
msgs
=
[]
msgs
=
[]
if
missing
:
msgs
.
append
(
self
.
issue_msg
.
format
(
problem
=
"misses"
,
mismatch
=
", "
.
join
(
sorted
(
missing
))))
if
missing
:
msgs
.
append
(
self
.
issue_msg
.
format
(
problem
=
"misses"
,
mismatch
=
", "
.
join
(
sorted
(
missing
))))
if
extra
:
msgs
.
append
(
self
.
issue_msg
.
format
(
problem
=
"has extra"
,
mismatch
=
", "
.
join
(
sorted
(
extra
))))
if
extra
:
msgs
.
append
(
self
.
issue_msg
.
format
(
problem
=
"has extra"
,
mismatch
=
", "
.
join
(
sorted
(
extra
))))
testcase
.
fail
(
self
.
action_msg
.
format
(
visitor
=
visitor
)
+
" "
+
" and "
.
join
(
msgs
))
self
.
testcase
.
fail
(
self
.
action_msg
.
format
(
visitor
=
visitor
)
+
" "
+
" and "
.
join
(
msgs
))
def
assertEmpty
(
self
,
testcase
,
visitor
,
got
):
def
assertEmpty
(
self
,
visitor
,
got
):
extra
=
set
(
got
)
extra
=
set
(
got
)
if
not
extra
:
return
if
not
extra
:
return
testcase
.
fail
(
self
.
action_msg
.
format
(
visitor
=
visitor
)
+
" "
+
self
.
issue_msg
.
format
(
problem
=
"has"
,
mismatch
=
", "
.
join
(
sorted
(
extra
))))
self
.
testcase
.
fail
(
self
.
action_msg
.
format
(
visitor
=
visitor
)
+
" "
+
self
.
issue_msg
.
format
(
problem
=
"has"
,
mismatch
=
", "
.
join
(
sorted
(
extra
))))
class
ExpectedPerms
(
object
):
class
ExpectedPerms
(
object
):
...
...
process/tests/test_perms.py
View file @
c2b190c8
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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