Commit cf4ae161 by Chris Rossi Committed by Diana Huang

Disambiguate script names. Unfortunately verbose.

parent d7d7327d
...@@ -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.
......
...@@ -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.send_email') @mock.patch(MODULE + 'send_triggered_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.send_email') @mock.patch(MODULE + 'send_triggered_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):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment