Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
38ad26d5
Commit
38ad26d5
authored
Dec 20, 2013
by
Chris Rossi
Committed by
Diana Huang
Jan 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test --force.
parent
0a5c25c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
2 deletions
+29
-2
lms/djangoapps/linkedin/management/commands/tests/test_findusers.py
+29
-2
No files found.
lms/djangoapps/linkedin/management/commands/tests/test_findusers.py
View file @
38ad26d5
...
...
@@ -5,14 +5,15 @@ import datetime
import
mock
import
pytz
import
StringIO
import
unittest
from
django.test
import
TestCase
from
linkedin.management.commands
import
linkedin_findusers
as
findusers
MODULE
=
'linkedin.management.commands.linkedin_findusers.'
class
FindUsersTests
(
unittest
.
TestCase
):
class
FindUsersTests
(
TestCase
):
"""
Tests for the findusers script.
"""
...
...
@@ -176,6 +177,32 @@ class FindUsersTests(unittest.TestCase):
self
.
assertEqual
(
users
[
9
]
.
linkedin
.
has_linkedin_account
,
None
)
self
.
assertTrue
(
command
.
stderr
.
getvalue
()
.
startswith
(
"WARNING"
))
@mock.patch
(
MODULE
+
'User'
)
@mock.patch
(
MODULE
+
'LinkedinAPI'
)
@mock.patch
(
MODULE
+
'get_call_limits'
)
def
test_command_success_recheck_with_force
(
self
,
get_call_limits
,
apicls
,
usercls
):
"""
Test recheck all users with API limit.
"""
command
=
findusers
.
Command
()
command
.
stderr
=
StringIO
.
StringIO
()
fut
=
command
.
handle
get_call_limits
.
return_value
=
(
9
,
6
,
42
)
api
=
apicls
.
return_value
users
=
[
mock
.
Mock
(
email
=
i
)
for
i
in
xrange
(
10
)]
for
user
in
users
:
user
.
linkedin
.
has_linkedin_account
=
None
usercls
.
objects
.
all
.
return_value
=
users
def
dummy_batch
(
emails
):
"Mock LinkedIn API."
return
[
email
%
2
==
0
for
email
in
emails
]
api
.
batch
=
dummy_batch
fut
(
force
=
True
)
self
.
assertEqual
([
u
.
linkedin
.
has_linkedin_account
for
u
in
users
],
[
i
%
2
==
0
for
i
in
xrange
(
10
)])
@mock.patch
(
MODULE
+
'get_call_limits'
)
def
test_command_no_api_calls
(
self
,
get_call_limits
):
"""
...
...
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