当前位置: 首页>>代码示例>>Python>>正文


Python SavedSearchFactory.send_email方法代码示例

本文整理汇总了Python中mysearches.tests.factories.SavedSearchFactory.send_email方法的典型用法代码示例。如果您正苦于以下问题:Python SavedSearchFactory.send_email方法的具体用法?Python SavedSearchFactory.send_email怎么用?Python SavedSearchFactory.send_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysearches.tests.factories.SavedSearchFactory的用法示例。


在下文中一共展示了SavedSearchFactory.send_email方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_inactive_user_receives_saved_search

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
 def test_inactive_user_receives_saved_search(self):
     self.assertEqual(len(mail.outbox), 0)
     self.user.is_active = False
     self.user.save()
     saved_search = SavedSearchFactory(user=self.user)
     saved_search.send_email()
     self.assertEqual(len(mail.outbox), 1)
开发者ID:zeus911,项目名称:MyJobs,代码行数:9,代码来源:test_models.py

示例2: test_email_contains_activate_link

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
    def test_email_contains_activate_link(self):
        search = SavedSearchFactory(user=self.user)
        self.assertTrue(self.user.is_active)
        search.send_email()
        email = mail.outbox.pop()
        self.assertFalse('activate your account' in email.body)

        self.user.is_active = False
        self.user.save()
        search.send_email()
        email = mail.outbox.pop()
        self.assertTrue('activate your account' in email.body)
开发者ID:zeus911,项目名称:MyJobs,代码行数:14,代码来源:test_models.py

示例3: test_unicode_in_saved_search

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
    def test_unicode_in_saved_search(self):
        """Tests that saved search urls with unicode don't cause errors."""
        search = SavedSearchFactory(
            user=self.user,
            url=u"warehouse.jobs/search?location=Roswell%2C+GA&q=Delivery+I"
                "+%E2%80%93+Material+Handler%2FDriver+Helper+%E2%80%93+3rd"
                "+Shift%2C+Part-time")

        try:
            search.send_email()
        except UnicodeEncodeError as e:
            self.fail(e)
开发者ID:kepinq,项目名称:MyJobs,代码行数:14,代码来源:test_models.py

示例4: test_send_search_email

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
    def test_send_search_email(self):
        search = SavedSearchFactory(user=self.user, is_active=False,
                                    url='www.my.jobs/search?q=new+search')
        search.send_email()
        self.assertEqual(len(mail.outbox), 1)

        email = mail.outbox.pop()
        self.assertEqual(email.from_email, settings.SAVED_SEARCH_EMAIL)
        self.assertEqual(email.to, [self.user.email])
        self.assertEqual(email.subject, search.label)
        self.assertTrue("table" in email.body)
        self.assertTrue(email.to[0] in email.body)
开发者ID:jpaezsa,项目名称:MyJobs,代码行数:14,代码来源:models.py

示例5: test_email_profile_completion

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
    def test_email_profile_completion(self):

        search = SavedSearchFactory(user=self.user)
        search.send_email()
        self.assertEqual(len(settings.PROFILE_COMPLETION_MODULES), 6)
        self.assert_modules_in_hrefs(settings.PROFILE_COMPLETION_MODULES)

        PrimaryNameFactory(user=self.user)

        search.send_email()

        new_modules = [module for module in settings.PROFILE_COMPLETION_MODULES
                       if module != 'name']
        self.assertEqual(len(new_modules), 5)
        self.assert_modules_in_hrefs(new_modules)
开发者ID:zeus911,项目名称:MyJobs,代码行数:17,代码来源:test_models.py

示例6: test_get_unsent_jobs

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
 def test_get_unsent_jobs(self):
     """
     When sending a saved search email, we should retrieve all new jobs since
     last send, not all new jobs based on frequency.
     """
     self.patcher.stop()
     self.patcher = patch('urllib2.urlopen',
                          return_file(time_=datetime.datetime.now() -
                                      datetime.timedelta(days=3)))
     self.mock_urlopen = self.patcher.start()
     last_sent = datetime.datetime.now() - datetime.timedelta(days=3)
     search = SavedSearchFactory(frequency='D',
                                 last_sent=last_sent,
                                 user=self.user,
                                 email=self.user.email)
     search.send_email()
     self.assertEqual(len(mail.outbox), 1)
开发者ID:zeus911,项目名称:MyJobs,代码行数:19,代码来源:test_models.py

示例7: test_saved_search_new_job_indicator

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
    def test_saved_search_new_job_indicator(self):
        """
        Partner saved searches should include indicators for unseen jobs, while
        job seeker saved searches should not.
        """
        new_job_indicator = '>New! <'
        search = SavedSearchFactory(user=self.user)
        search.send_email()
        search_email = mail.outbox.pop()
        new_jobs = self.num_occurrences(search_email.body,
                                        new_job_indicator)
        self.assertEqual(len(new_jobs), 0)

        self.partner_search.send_email()
        partner_search_email = mail.outbox.pop()
        new_jobs = self.num_occurrences(partner_search_email.body,
                                        new_job_indicator)
        self.assertEqual(len(new_jobs), 1)
开发者ID:zeus911,项目名称:MyJobs,代码行数:20,代码来源:test_models.py

示例8: test_saved_search_all_jobs_link

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
    def test_saved_search_all_jobs_link(self):
        search = SavedSearchFactory(user=self.user)
        search.send_email()

        email = mail.outbox.pop()
        # When search.url does not start with my.jobs, use it as the all jobs
        # link
        self.assertFalse(search.url.startswith('http://my.jobs'))
        self.assertNotEqual(email.body.find(search.url), -1)

        # When search.url starts with my.jobs, strip /feed/rss from search.feed
        # if it exists and use that as the all jobs link
        search.url = 'http://my.jobs/' + '1'*32
        search.save()
        search.send_email()
        email = mail.outbox.pop()
        self.assertEqual(email.body.find(search.url),
                         -1)
        self.assertNotEqual(email.body.find(search.feed.replace('/feed/rss', '')),
                            -1)
开发者ID:zeus911,项目名称:MyJobs,代码行数:22,代码来源:test_models.py

示例9: SavedSearchSendingTests

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
class SavedSearchSendingTests(MyJobsBase):
    def setUp(self):
        super(SavedSearchSendingTests, self).setUp()
        self.feed = 'http://rushenterprises-veterans.jobs/alabama/usa/jobs/feed/rss'
        self.user = UserFactory()
        self.saved_search = SavedSearchFactory(user=self.user, feed=self.feed,
                                               frequency='D')
        self.company = CompanyFactory()
        self.partner = PartnerFactory(owner=self.company)
        self.contact = ContactFactory(user=self.user,
                                      partner=self.partner)
        self.partner_search = PartnerSavedSearchFactory(user=self.user,
                                                        feed=self.feed,
                                                        frequency='D',
                                                        created_by=self.user,
                                                        provider=self.company,
                                                        partner=self.partner)
        mail.outbox = []

    @patch('urllib2.urlopen')
    def test_all_jobs_new(self, urlopen_mock):
        mock_obj = Mock()
        mock_obj.read.side_effect = [jobs, jobs, jobs]
        urlopen_mock.return_value = mock_obj

        three_days_ago = datetime.datetime.now() - datetime.timedelta(days=365)
        self.partner_search.last_sent = three_days_ago
        self.saved_search.last_sent = three_days_ago
        self.partner_search.save()
        self.saved_search.save()

        # All of the jobs were sent within the past year, so if we set
        # last_sent to one year ago all of the jobs should be old.
        self.saved_search.send_email()
        email = mail.outbox.pop()
        self.assertIn('Showing the top 3 jobs', email.body)

        self.partner_search.send_email()
        email = mail.outbox.pop()
        self.assertIn('Showing the top 3 jobs', email.body)

    @patch('urllib2.urlopen')
    def test_some_jobs_new(self, urlopen_mock):
        mock_obj = Mock()
        mock_obj.read.side_effect = [jobs, jobs, jobs]
        urlopen_mock.return_value = mock_obj

        three_days_ago = datetime.datetime.now() - datetime.timedelta(days=3)
        self.partner_search.last_sent = three_days_ago
        self.saved_search.last_sent = three_days_ago
        self.partner_search.save()
        self.saved_search.save()

        # One job was sent within the past 3 days, so if we set last_sent to
        # three days ago one of the jobs should be old.
        self.saved_search.send_email()
        email = mail.outbox.pop()
        self.assertIn('Showing the top job', email.body)

        self.partner_search.send_email()
        email = mail.outbox.pop()
        self.assertIn('Showing the top 3 jobs', email.body)

    @patch('urllib2.urlopen')
    def test_no_jobs_new(self, urlopen_mock):
        mock_obj = Mock()
        mock_obj.read.side_effect = [jobs, jobs, jobs]
        urlopen_mock.return_value = mock_obj

        self.partner_search.last_sent = datetime.datetime.now()
        self.saved_search.last_sent = datetime.datetime.now()
        self.partner_search.save()
        self.saved_search.save()

        # All jobs were sent over 2 days ago, so if we set last_sent to
        # today none of the jobs should be old.
        self.saved_search.send_email()
        self.assertEqual(len(mail.outbox), 0)

        self.partner_search.send_email()
        email = mail.outbox.pop()
        self.assertIn('Showing the top 3 jobs', email.body)

    @patch('urllib2.urlopen')
    def test_partner_saved_search_backfill(self, urlopen_mock):
        mock_obj = Mock()
        mock_obj.read.side_effect = [jobs, jobs, jobs, jobs, jobs, jobs]
        urlopen_mock.return_value = mock_obj

        # Make it so there should be no new jobs.
        self.partner_search.last_sent = datetime.datetime.now()
        self.partner_search.save()

        # jobs_per_email is default, so all 3 should get sent.
        self.partner_search.send_email()
        email = mail.outbox.pop()
        self.assertIn('Showing the top 3 jobs', email.body)

        self.partner_search.jobs_per_email = 2
        self.partner_search.save()
#.........这里部分代码省略.........
开发者ID:zeus911,项目名称:MyJobs,代码行数:103,代码来源:test_models.py

示例10: test_saved_search_no_jobs

# 需要导入模块: from mysearches.tests.factories import SavedSearchFactory [as 别名]
# 或者: from mysearches.tests.factories.SavedSearchFactory import send_email [as 别名]
    def test_saved_search_no_jobs(self):
        search = SavedSearchFactory(feed='http://google.com', user=self.user)
        search.send_email()

        self.assertEqual(len(mail.outbox), 0)
开发者ID:zeus911,项目名称:MyJobs,代码行数:7,代码来源:test_models.py


注:本文中的mysearches.tests.factories.SavedSearchFactory.send_email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。