Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ai
nospam
Commits
346f57cc
Commit
346f57cc
authored
Aug 22, 2012
by
ale
Browse files
fix stats() and add a test for it
parent
73753983
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
nospam/api.py
nospam/api.py
+2
-2
nospam/tests/test_api.py
nospam/tests/test_api.py
+9
-1
No files found.
nospam/api.py
View file @
346f57cc
...
...
@@ -119,8 +119,8 @@ class NoSpam(object):
def
stats
(
self
,
site
=
None
):
if
not
site
:
site
=
'@all'
return
(
self
.
_counters
.
get
(
'
ham:
%s'
%
site
,
0
),
self
.
_counters
.
get
(
'
spam:
%s'
%
site
,
0
))
return
(
self
.
_counters
.
get
(
'
comments{kind=ham,site=
%s
}
'
%
site
,
0
),
self
.
_counters
.
get
(
'
comments{kind=spam,site=
%s
}
'
%
site
,
0
))
class
BlogSpamCompatibleAPI
(
object
):
...
...
nospam/tests/test_api.py
View file @
346f57cc
...
...
@@ -59,7 +59,15 @@ class TestAPI(unittest.TestCase):
del
self
.
ns
self
.
ns
=
NoSpam
(
self
.
config
)
self
.
ns
.
_incr_counter
(
'test'
)
self
.
assertEquals
(
2
,
self
.
ns
.
_counters
[
'test:@all'
])
self
.
assertEquals
(
2
,
self
.
ns
.
_counters
[
'comments{kind=test,site=@all}'
])
def
test_stats
(
self
):
self
.
ns
.
_incr_counter
(
'spam'
,
'example.org'
)
self
.
ns
.
_incr_counter
(
'spam'
,
'example.org'
)
self
.
ns
.
_incr_counter
(
'ham'
,
'example.org'
)
ham
,
spam
=
self
.
ns
.
stats
(
'example.org'
)
self
.
assertEquals
(
1
,
ham
)
self
.
assertEquals
(
2
,
spam
)
if
__name__
==
'__main__'
:
...
...
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