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


Python factories.SavedSearchFactory类代码示例

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


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

示例1: test_requeue_weekly_saved_search

    def test_requeue_weekly_saved_search(self):
        """
        Tests that weekly saved searches are requeued correctly individually in
        addition to as part of a digest.
        """
        today = datetime.date.today()
        two_days_ago = today.isoweekday() - 2
        two_month_days_ago = today.day - 2
        if two_days_ago <= 0:
            # Dates can't be negative or zero
            two_days_ago += 7
        if two_month_days_ago == 0:
            # According to mysearches/models.py, we can't have saved searches on
            # the 31st. If two_month_days_ago==0, this would be the 31st.
            two_days_ago -= 1

        digest = SavedSearchDigestFactory(user=self.user, is_active=True)
        search = SavedSearchFactory(user=self.user, is_active=True,
                                    frequency='W', day_of_week=two_days_ago)

        self.requeue(search, digest)

        digest.is_active = False
        digest.save()
        search.last_sent = None
        search.save()
        mail.outbox = []

        self.requeue(search, digest)
开发者ID:kepinq,项目名称:MyJobs,代码行数:29,代码来源:test_models.py

示例2: test_requeue_monthly_saved_search

    def test_requeue_monthly_saved_search(self):
        """
        Tests that monthly saved searches are requeued correctly individually
        in addition to as part of a digest.
        """
        today = datetime.date.today()
        two_days_ago = today.day - 2
        if two_days_ago < 0:
            two_days_ago += 31
        elif two_days_ago == 0:
            two_days_ago = 30

        digest = SavedSearchDigestFactory(user=self.user, is_active=True)
        search = SavedSearchFactory(user=self.user, is_active=True,
                                    frequency='M', day_of_month=two_days_ago)

        self.requeue(search, digest)

        digest.is_active = False
        digest.save()
        search.last_sent = None
        search.save()
        mail.outbox = []

        self.requeue(search, digest)
开发者ID:kepinq,项目名称:MyJobs,代码行数:25,代码来源:test_models.py

示例3: test_inactive_user_receives_saved_search

 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,代码行数:7,代码来源:test_models.py

示例4: test_email_contains_activate_link

    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,代码行数:12,代码来源:test_models.py

示例5: test_unicode_in_saved_search

    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,代码行数:12,代码来源:test_models.py

示例6: test_send_initial_email

    def test_send_initial_email(self):
        search = SavedSearchFactory(user=self.user, is_active=False,
                                    url='www.my.jobs/search?q=new+search')
        search.send_initial_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("My.jobs New Saved Search" in email.subject, True)
        self.assertTrue("table" in email.body)
        self.assertTrue(email.to[0] in email.body)
开发者ID:jpaezsa,项目名称:MyJobs,代码行数:12,代码来源:models.py

示例7: test_email_profile_completion

    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,代码行数:15,代码来源:test_models.py

示例8: test_send_update_email

    def test_send_update_email(self):
        search = SavedSearchFactory(user=self.user, is_active=False,
                                    url='www.my.jobs/search?q=new+search')
        search.send_update_email('Your search is updated')
        self.assertEqual(len(mail.outbox), 1)
        log = SavedSearchLog.objects.get()
        self.assertTrue('Jobs are not sent' in log.reason)
        self.assertTrue(log.was_sent)

        email = mail.outbox.pop()
        self.assertEqual(email.from_email, 'My.jobs Saved Search <[email protected]>')
        self.assertEqual(email.to, [self.user.email])
        self.assertEqual("My.jobs Saved Search Updated" in email.subject, True)
        self.assertTrue("table" in email.body)
        self.assertTrue("Your search is updated" in email.body)
        self.assertTrue(email.to[0] in email.body)
开发者ID:zeus911,项目名称:MyJobs,代码行数:16,代码来源:test_models.py

示例9: test_saved_search_invitation_context

    def test_saved_search_invitation_context(self):
        """
        Test that creating an invitation context from a saved search instance
        produces a context with a message, the saved search itself, an unsent
        initial email, and whether that saved search is text only.

        """
        saved_search = SavedSearchFactory(user=self.user, text_only=True)
        context = invitation_context(saved_search)

        self.assertEqual(context, {
            "message": " in order to begin receiving their available job "
                       "opportunities on a regular basis.",
            "saved_search": saved_search,
            "initial_search_email": saved_search.initial_email(send=False),
            "text_only": saved_search.text_only})
开发者ID:DirectEmployers,项目名称:MyJobs,代码行数:16,代码来源:test_helpers.py

示例10: test_get_unsent_jobs

 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,代码行数:17,代码来源:test_models.py

示例11: test_saved_search_new_job_indicator

    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,代码行数:18,代码来源:test_models.py

示例12: test_initial_email

    def test_initial_email(self):
        search = SavedSearchFactory(user=self.user, is_active=False,
                                    url='www.my.jobs/search?q=new+search')
        search.initial_email()
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(SavedSearchLog.objects.count(), 1)
        log = SavedSearchLog.objects.get()
        self.assertTrue('Jobs are not sent' in log.reason)
        self.assertTrue(log.was_sent)

        email = mail.outbox.pop()
        self.assertEqual(email.from_email, 'My.jobs Saved Search <[email protected]>')
        self.assertEqual(email.to, [self.user.email])
        self.assertEqual("My.jobs New Saved Search" in email.subject, True)
        self.assertTrue("table" in email.body)
        self.assertTrue(email.to[0] in email.body)
        # Search url appears twice - once displaying the saved search source
        # and once in the view link.
        self.assertEqual(email.body.count(search.url), 2)
开发者ID:zeus911,项目名称:MyJobs,代码行数:19,代码来源:test_models.py

示例13: test_requeue_monthly_saved_search

    def test_requeue_monthly_saved_search(self):
        """
        Tests that monthly saved searches are requeued correctly individually
        in addition to as part of a digest.
        """
        today = datetime.date.today().day
        last_week = today - 7
        if last_week <= 0:
            last_week += 31
        digest = SavedSearchDigestFactory(user=self.user,
                                          is_active=True)
        search = SavedSearchFactory(user=self.user, is_active=True,
                                    frequency='M', day_of_month=last_week)

        self.requeue(search, digest)

        digest.is_active = False
        digest.save()
        search.last_sent = None
        search.save()
        mail.outbox = []

        self.requeue(search, digest)
开发者ID:wejhink,项目名称:MyJobs,代码行数:23,代码来源:test_models.py

示例14: setUp

    def setUp(self):
        super(CronEventTests, self).setUp()
        # I'm using SavedSearch for these tests, but you can use any
        # model with a DateTimeField for the "*_with_field" option, and
        # any object for the "*_no_field" option.
        # It might actually be worth using additional object types
        # in future tests.
        yesterday = datetime.now() - timedelta(1)
        self.saved_search = SavedSearchFactory(last_sent=yesterday)

        model = self.saved_search._meta.model
        self.saved_search_contenttype = ContentType.objects.get_for_model(model)
        cron_kwargs = {'model': self.saved_search_contenttype}
        self.cron_event_no_field = factories.CronEventFactory(**cron_kwargs)
        cron_kwargs['field'] = 'last_sent'
        self.cron_event_with_field = factories.CronEventFactory(**cron_kwargs)
开发者ID:abdulfiroz007,项目名称:MyJobs,代码行数:16,代码来源:test_models.py

示例15: setUp

 def setUp(self):
     super(SavedSearchSendingTests, self).setUp()
     self.feed = 'http://rushenterprises-veterans.jobs/alabama/usa/jobs/feed/rss'
     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 = []
开发者ID:kepinq,项目名称:MyJobs,代码行数:16,代码来源:test_models.py


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