Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
blog
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
cubes
blog
Commits
f79c5314a68f
Commit
f79c5314a68f
authored
15 years ago
by
Katia Saurfelt
Browse files
Options
Downloads
Patches
Plain Diff
#342714: add [appid] and blog title to the mail'subject'
parent
0576c4b660e1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hooks.py
+5
-0
5 additions, 0 deletions
hooks.py
test/unittest_blog.py
+35
-0
35 additions, 0 deletions
test/unittest_blog.py
with
40 additions
and
0 deletions
hooks.py
+
5
−
0
View file @
f79c5314
...
...
@@ -4,3 +4,8 @@
"""
get notified from new blogs
"""
accepts
=
(
'
BlogEntry
'
,)
content_attr
=
'
content
'
def
subject
(
self
):
entity
=
self
.
entity
(
0
)
return
'
[%s] %s
'
%
(
self
.
config
.
appid
,
entity
.
dc_title
())
This diff is collapsed.
Click to expand it.
test/unittest_blog.py
0 → 100644
+
35
−
0
View file @
f79c5314
"""
Blog unit tests
"""
import
re
from
logilab.common.testlib
import
unittest_main
,
mock_object
from
cubicweb.devtools.apptest
import
ControllerTC
from
cubicweb.devtools.testlib
import
WebTest
from
email.Header
import
decode_header
from
cubicweb.sobjects.notification
import
RenderAndSendNotificationView
from
cubicweb.server.hookhelper
import
SendMailOp
class
BlogTests
(
ControllerTC
):
"""
test blog specific behaviours
"""
def
test_notifications
(
self
):
cubicweb_blog
=
self
.
add_entity
(
'
Blog
'
,
title
=
u
'
cubicweb
'
,
description
=
u
"
cubicweb c
'
est beau
"
)
blog_entry_1
=
self
.
add_entity
(
'
BlogEntry
'
,
title
=
u
"
hop
"
,
content
=
u
"
cubicweb hop
"
)
self
.
execute
(
'
SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s
'
%
{
'
beid
'
:
cubicweb_blog
.
eid
,
'
eeid
'
:
blog_entry_1
.
eid
})
blog_entry_2
=
self
.
add_entity
(
'
BlogEntry
'
,
title
=
u
"
yes
"
,
content
=
u
"
cubicweb yes
"
)
self
.
execute
(
'
SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s
'
%
{
'
beid
'
:
cubicweb_blog
.
eid
,
'
eeid
'
:
blog_entry_2
.
eid
})
session
=
self
.
session
()
for
op
in
session
.
pending_operations
:
if
isinstance
(
op
,
RenderAndSendNotificationView
):
op
.
precommit_event
()
sendmailops
=
[
op
for
op
in
session
.
pending_operations
if
isinstance
(
op
,
SendMailOp
)]
self
.
assertEquals
(
len
(
sendmailops
),
1
)
sendmailop
=
sendmailops
[
0
]
sent
=
[
re
.
sub
(
'
#\d+
'
,
'
#EID
'
,
decode_header
(
msg
[
'
subject
'
].
encode
())[
0
][
0
])
for
msg
,
recipients
in
op
.
to_send
]
self
.
assertListEquals
(
sent
,
[
'
[data] hop
'
,
'
[data] yes
'
])
if
__name__
==
'
__main__
'
:
unittest_main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment