Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
89325b9c
authored
Jun 09, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: test local_periodic_tasks
parent
97d24537
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
+31
-1
circle/dashboard/tasks/local_periodic_tasks.py
+1
-1
circle/dashboard/tests/test_periodic_task.py
+30
-0
No files found.
circle/dashboard/tasks/local_periodic_tasks.py
View file @
89325b9c
...
@@ -62,7 +62,7 @@ def send_email_notifications():
...
@@ -62,7 +62,7 @@ def send_email_notifications():
logger
.
error
(
"Failed to send mail to
%
s"
,
user
,
exc_info
=
True
)
logger
.
error
(
"Failed to send mail to
%
s"
,
user
,
exc_info
=
True
)
else
:
else
:
logger
.
info
(
"Delivered notifications
%
s"
,
logger
.
info
(
"Delivered notifications
%
s"
,
" "
.
join
(
j
.
pk
for
j
in
i
))
" "
.
join
(
unicode
(
j
.
pk
)
for
j
in
i
))
for
j
in
i
:
for
j
in
i
:
j
.
status
=
j
.
STATUS
.
delivered
j
.
status
=
j
.
STATUS
.
delivered
j
.
save
()
j
.
save
()
circle/dashboard/tests/test_periodic_task.py
0 → 100644
View file @
89325b9c
import
unittest
from
mock
import
patch
,
MagicMock
from
..models
import
Notification
from
..tasks
import
local_periodic_tasks
@patch.object
(
local_periodic_tasks
,
'send_mail'
)
@patch.object
(
Notification
,
'objects'
)
class
EmailNotificationTestCase
(
unittest
.
TestCase
):
def
test_not_sending
(
self
,
no
,
sm
):
fake
=
MagicMock
(
spec
=
Notification
)
fake
.
to
.
profile
.
email_notifications
=
False
no
.
filter
.
return_value
=
[
fake
]
local_periodic_tasks
.
send_email_notifications
()
assert
not
sm
.
called
def
test_sending
(
self
,
no
,
sm
):
fake
=
MagicMock
(
spec
=
Notification
)
fake
.
to
.
profile
.
__unicode__
.
return_value
=
"user"
fake
.
to
.
email
=
"mail"
fake
.
to
.
profile
.
email_notifications
=
True
fake
.
to
.
profile
.
preferred_language
=
"en"
fake
.
subject
=
"subj"
fake
.
message
=
"msg"
no
.
filter
.
return_value
=
[
fake
]
local_periodic_tasks
.
send_email_notifications
()
assert
sm
.
called
assert
fake
.
status
==
fake
.
STATUS
.
delivered
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