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
cf4ae161
Commit
cf4ae161
authored
Dec 19, 2013
by
Chris Rossi
Committed by
Diana Huang
Jan 16, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disambiguate script names. Unfortunately verbose.
parent
d7d7327d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
31 deletions
+34
-31
lms/djangoapps/linkedin/management/commands/linkedin_findusers.py
+0
-0
lms/djangoapps/linkedin/management/commands/linkedin_login.py
+0
-0
lms/djangoapps/linkedin/management/commands/linkedin_mailusers.py
+0
-0
lms/djangoapps/linkedin/management/commands/tests/test_findusers.py
+22
-21
lms/djangoapps/linkedin/management/commands/tests/test_mailusers.py
+12
-10
No files found.
lms/djangoapps/linkedin/management/commands/findusers.py
→
lms/djangoapps/linkedin/management/commands/
linkedin_
findusers.py
View file @
cf4ae161
File moved
lms/djangoapps/linkedin/management/commands/login.py
→
lms/djangoapps/linkedin/management/commands/l
inkedin_l
ogin.py
View file @
cf4ae161
File moved
lms/djangoapps/linkedin/management/commands/mailusers.py
→
lms/djangoapps/linkedin/management/commands/
linkedin_
mailusers.py
View file @
cf4ae161
File moved
lms/djangoapps/linkedin/management/commands/tests/test_findusers.py
View file @
cf4ae161
...
@@ -7,8 +7,9 @@ import pytz
...
@@ -7,8 +7,9 @@ import pytz
import
StringIO
import
StringIO
import
unittest
import
unittest
from
linkedin.management.commands
import
linkedin_findusers
as
findusers
from
linkedin.management.commands
import
findusers
MODULE
=
'linkedin.management.commands.linkedin_findusers.'
class
FindUsersTests
(
unittest
.
TestCase
):
class
FindUsersTests
(
unittest
.
TestCase
):
...
@@ -16,7 +17,7 @@ class FindUsersTests(unittest.TestCase):
...
@@ -16,7 +17,7 @@ class FindUsersTests(unittest.TestCase):
Tests for the findusers script.
Tests for the findusers script.
"""
"""
@mock.patch
(
'linkedin.management.commands.findusers.
timezone'
)
@mock.patch
(
MODULE
+
'
timezone'
)
def
test_get_call_limits_in_safe_harbor
(
self
,
timezone
):
def
test_get_call_limits_in_safe_harbor
(
self
,
timezone
):
"""
"""
We should be able to perform unlimited API calls during "safe harbor".
We should be able to perform unlimited API calls during "safe harbor".
...
@@ -33,7 +34,7 @@ class FindUsersTests(unittest.TestCase):
...
@@ -33,7 +34,7 @@ class FindUsersTests(unittest.TestCase):
2013
,
12
,
15
,
7
,
59
,
tzinfo
=
tzinfo
)
2013
,
12
,
15
,
7
,
59
,
tzinfo
=
tzinfo
)
self
.
assertEqual
(
fut
(),
(
-
1
,
80
,
1
))
self
.
assertEqual
(
fut
(),
(
-
1
,
80
,
1
))
@mock.patch
(
'linkedin.management.commands.findusers.
timezone'
)
@mock.patch
(
MODULE
+
'
timezone'
)
def
test_get_call_limits_in_business_hours
(
self
,
timezone
):
def
test_get_call_limits_in_business_hours
(
self
,
timezone
):
"""
"""
During business hours we shouldn't be able to make any API calls.
During business hours we shouldn't be able to make any API calls.
...
@@ -50,7 +51,7 @@ class FindUsersTests(unittest.TestCase):
...
@@ -50,7 +51,7 @@ class FindUsersTests(unittest.TestCase):
2013
,
12
,
16
,
8
,
1
,
tzinfo
=
tzinfo
)
2013
,
12
,
16
,
8
,
1
,
tzinfo
=
tzinfo
)
self
.
assertEqual
(
fut
(),
(
0
,
0
,
0
))
self
.
assertEqual
(
fut
(),
(
0
,
0
,
0
))
@mock.patch
(
'linkedin.management.commands.findusers.
timezone'
)
@mock.patch
(
MODULE
+
'
timezone'
)
def
test_get_call_limits_on_weeknights
(
self
,
timezone
):
def
test_get_call_limits_on_weeknights
(
self
,
timezone
):
"""
"""
On weeknights outside of "safe harbor" we can only make limited API
On weeknights outside of "safe harbor" we can only make limited API
...
@@ -65,10 +66,10 @@ class FindUsersTests(unittest.TestCase):
...
@@ -65,10 +66,10 @@ class FindUsersTests(unittest.TestCase):
2013
,
12
,
11
,
7
,
59
,
tzinfo
=
tzinfo
)
2013
,
12
,
11
,
7
,
59
,
tzinfo
=
tzinfo
)
self
.
assertEqual
(
fut
(),
(
500
,
80
,
1
))
self
.
assertEqual
(
fut
(),
(
500
,
80
,
1
))
@mock.patch
(
'linkedin.management.commands.findusers.
time'
)
@mock.patch
(
MODULE
+
'
time'
)
@mock.patch
(
'linkedin.management.commands.findusers.
User'
)
@mock.patch
(
MODULE
+
'
User'
)
@mock.patch
(
'linkedin.management.commands.findusers.
LinkedinAPI'
)
@mock.patch
(
MODULE
+
'
LinkedinAPI'
)
@mock.patch
(
'linkedin.management.commands.findusers.
get_call_limits'
)
@mock.patch
(
MODULE
+
'
get_call_limits'
)
def
test_command_success_recheck_no_limits
(
self
,
get_call_limits
,
apicls
,
def
test_command_success_recheck_no_limits
(
self
,
get_call_limits
,
apicls
,
usercls
,
time
):
usercls
,
time
):
"""
"""
...
@@ -89,10 +90,10 @@ class FindUsersTests(unittest.TestCase):
...
@@ -89,10 +90,10 @@ class FindUsersTests(unittest.TestCase):
self
.
assertEqual
([
u
.
linkedin
.
has_linkedin_account
for
u
in
users
],
self
.
assertEqual
([
u
.
linkedin
.
has_linkedin_account
for
u
in
users
],
[
i
%
2
==
0
for
i
in
xrange
(
10
)])
[
i
%
2
==
0
for
i
in
xrange
(
10
)])
@mock.patch
(
'linkedin.management.commands.findusers.
time'
)
@mock.patch
(
MODULE
+
'
time'
)
@mock.patch
(
'linkedin.management.commands.findusers.
User'
)
@mock.patch
(
MODULE
+
'
User'
)
@mock.patch
(
'linkedin.management.commands.findusers.
LinkedinAPI'
)
@mock.patch
(
MODULE
+
'
LinkedinAPI'
)
@mock.patch
(
'linkedin.management.commands.findusers.
get_call_limits'
)
@mock.patch
(
MODULE
+
'
get_call_limits'
)
def
test_command_success_no_recheck_no_limits
(
self
,
get_call_limits
,
apicls
,
def
test_command_success_no_recheck_no_limits
(
self
,
get_call_limits
,
apicls
,
usercls
,
time
):
usercls
,
time
):
"""
"""
...
@@ -119,10 +120,10 @@ class FindUsersTests(unittest.TestCase):
...
@@ -119,10 +120,10 @@ class FindUsersTests(unittest.TestCase):
self
.
assertEqual
([
u
.
linkedin
.
has_linkedin_account
for
u
in
users
],
self
.
assertEqual
([
u
.
linkedin
.
has_linkedin_account
for
u
in
users
],
[
i
%
2
==
0
for
i
in
xrange
(
10
)])
[
i
%
2
==
0
for
i
in
xrange
(
10
)])
@mock.patch
(
'linkedin.management.commands.findusers.
time'
)
@mock.patch
(
MODULE
+
'
time'
)
@mock.patch
(
'linkedin.management.commands.findusers.
User'
)
@mock.patch
(
MODULE
+
'
User'
)
@mock.patch
(
'linkedin.management.commands.findusers.
LinkedinAPI'
)
@mock.patch
(
MODULE
+
'
LinkedinAPI'
)
@mock.patch
(
'linkedin.management.commands.findusers.
get_call_limits'
)
@mock.patch
(
MODULE
+
'
get_call_limits'
)
def
test_command_success_no_recheck_no_users
(
self
,
get_call_limits
,
apicls
,
def
test_command_success_no_recheck_no_users
(
self
,
get_call_limits
,
apicls
,
usercls
,
time
):
usercls
,
time
):
"""
"""
...
@@ -145,10 +146,10 @@ class FindUsersTests(unittest.TestCase):
...
@@ -145,10 +146,10 @@ class FindUsersTests(unittest.TestCase):
self
.
assertEqual
([
u
.
linkedin
.
has_linkedin_account
for
u
in
users
],
self
.
assertEqual
([
u
.
linkedin
.
has_linkedin_account
for
u
in
users
],
[
i
%
2
==
0
for
i
in
xrange
(
10
)])
[
i
%
2
==
0
for
i
in
xrange
(
10
)])
@mock.patch
(
'linkedin.management.commands.findusers.
time'
)
@mock.patch
(
MODULE
+
'
time'
)
@mock.patch
(
'linkedin.management.commands.findusers.
User'
)
@mock.patch
(
MODULE
+
'
User'
)
@mock.patch
(
'linkedin.management.commands.findusers.
LinkedinAPI'
)
@mock.patch
(
MODULE
+
'
LinkedinAPI'
)
@mock.patch
(
'linkedin.management.commands.findusers.
get_call_limits'
)
@mock.patch
(
MODULE
+
'
get_call_limits'
)
def
test_command_success_recheck_with_limit
(
self
,
get_call_limits
,
apicls
,
def
test_command_success_recheck_with_limit
(
self
,
get_call_limits
,
apicls
,
usercls
,
time
):
usercls
,
time
):
"""
"""
...
@@ -175,7 +176,7 @@ class FindUsersTests(unittest.TestCase):
...
@@ -175,7 +176,7 @@ class FindUsersTests(unittest.TestCase):
self
.
assertEqual
(
users
[
9
]
.
linkedin
.
has_linkedin_account
,
None
)
self
.
assertEqual
(
users
[
9
]
.
linkedin
.
has_linkedin_account
,
None
)
self
.
assertTrue
(
command
.
stderr
.
getvalue
()
.
startswith
(
"WARNING"
))
self
.
assertTrue
(
command
.
stderr
.
getvalue
()
.
startswith
(
"WARNING"
))
@mock.patch
(
'linkedin.management.commands.findusers.
get_call_limits'
)
@mock.patch
(
MODULE
+
'
get_call_limits'
)
def
test_command_no_api_calls
(
self
,
get_call_limits
):
def
test_command_no_api_calls
(
self
,
get_call_limits
):
"""
"""
Test rechecking all users with no API limits.
Test rechecking all users with no API limits.
...
...
lms/djangoapps/linkedin/management/commands/tests/test_mailusers.py
View file @
cf4ae161
...
@@ -5,7 +5,9 @@ import json
...
@@ -5,7 +5,9 @@ import json
import
mock
import
mock
import
unittest
import
unittest
from
linkedin.management.commands
import
mailusers
from
linkedin.management.commands
import
linkedin_mailusers
as
mailusers
MODULE
=
'linkedin.management.commands.linkedin_mailusers.'
class
MailusersTests
(
unittest
.
TestCase
):
class
MailusersTests
(
unittest
.
TestCase
):
...
@@ -13,9 +15,9 @@ class MailusersTests(unittest.TestCase):
...
@@ -13,9 +15,9 @@ class MailusersTests(unittest.TestCase):
Test mail users command.
Test mail users command.
"""
"""
@mock.patch
(
'linkedin.management.commands.mailusers.sen
d_email'
)
@mock.patch
(
MODULE
+
'send_triggere
d_email'
)
@mock.patch
(
'linkedin.management.commands.mailusers.
GeneratedCertificate'
)
@mock.patch
(
MODULE
+
'
GeneratedCertificate'
)
@mock.patch
(
'linkedin.management.commands.mailusers.
LinkedIn'
)
@mock.patch
(
MODULE
+
'
LinkedIn'
)
def
test_mail_users
(
self
,
linkedin
,
certificates
,
send_email
):
def
test_mail_users
(
self
,
linkedin
,
certificates
,
send_email
):
"""
"""
Test emailing users.
Test emailing users.
...
@@ -48,9 +50,9 @@ class MailusersTests(unittest.TestCase):
...
@@ -48,9 +50,9 @@ class MailusersTests(unittest.TestCase):
self
.
assertEqual
(
json
.
loads
(
fred
.
emailed_courses
),
[
1
,
2
])
self
.
assertEqual
(
json
.
loads
(
fred
.
emailed_courses
),
[
1
,
2
])
self
.
assertEqual
(
json
.
loads
(
barney
.
emailed_courses
),
[
3
])
self
.
assertEqual
(
json
.
loads
(
barney
.
emailed_courses
),
[
3
])
@mock.patch
(
'linkedin.management.commands.mailusers.
send_grandfather_email'
)
@mock.patch
(
MODULE
+
'
send_grandfather_email'
)
@mock.patch
(
'linkedin.management.commands.mailusers.
GeneratedCertificate'
)
@mock.patch
(
MODULE
+
'
GeneratedCertificate'
)
@mock.patch
(
'linkedin.management.commands.mailusers.
LinkedIn'
)
@mock.patch
(
MODULE
+
'
LinkedIn'
)
def
test_mail_users_grandfather
(
self
,
linkedin
,
certificates
,
send_email
):
def
test_mail_users_grandfather
(
self
,
linkedin
,
certificates
,
send_email
):
"""
"""
Test sending grandfather emails.
Test sending grandfather emails.
...
@@ -82,9 +84,9 @@ class MailusersTests(unittest.TestCase):
...
@@ -82,9 +84,9 @@ class MailusersTests(unittest.TestCase):
self
.
assertEqual
(
json
.
loads
(
fred
.
emailed_courses
),
[
1
,
2
])
self
.
assertEqual
(
json
.
loads
(
fred
.
emailed_courses
),
[
1
,
2
])
self
.
assertEqual
(
json
.
loads
(
barney
.
emailed_courses
),
[
3
])
self
.
assertEqual
(
json
.
loads
(
barney
.
emailed_courses
),
[
3
])
@mock.patch
(
'linkedin.management.commands.mailusers.sen
d_email'
)
@mock.patch
(
MODULE
+
'send_triggere
d_email'
)
@mock.patch
(
'linkedin.management.commands.mailusers.
GeneratedCertificate'
)
@mock.patch
(
MODULE
+
'
GeneratedCertificate'
)
@mock.patch
(
'linkedin.management.commands.mailusers.
LinkedIn'
)
@mock.patch
(
MODULE
+
'
LinkedIn'
)
def
test_mail_users_only_new_courses
(
self
,
linkedin
,
certificates
,
def
test_mail_users_only_new_courses
(
self
,
linkedin
,
certificates
,
send_email
):
send_email
):
"""
"""
...
...
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