Esempio n. 1
0
    def test_invoice_send_invoice_email(self):
        self.create_purchased_job()
        group, _ = Group.objects.get_or_create(name=Product.ADMIN_GROUP_NAME)

        # No one to receive the email.
        self.purchased_product.invoice.send_invoice_email()
        self.assertEqual(len(mail.outbox), 0)

        # Only recipient is specified recipient.
        self.purchased_product.invoice.send_invoice_email(other_recipients=['*****@*****.**'])
        self.assertItemsEqual(mail.outbox[0].to,
                              ['*****@*****.**'])

        mail.outbox = []

        # Only recipients are admins.
        user = CompanyUserFactory(user=self.user, company=self.company)
        user.group.add(group)
        user.save()
        self.purchased_product.invoice.send_invoice_email()
        self.assertItemsEqual(mail.outbox[0].to,
                              [u'*****@*****.**'])
        self.assertItemsEqual(mail.outbox[0].from_email,
                              '*****@*****.**')

        mail.outbox = []

        self.site.email_domain = 'test.domain'
        self.site.save()

        # Recipients are admins + specified recipients.
        self.purchased_product.invoice.send_invoice_email(other_recipients=['*****@*****.**'])
        self.assertItemsEqual(mail.outbox[0].to,
                              ['*****@*****.**', u'*****@*****.**'])
        self.assertEqual(mail.outbox[0].from_email,
                              '*****@*****.**')

        mail.outbox = []

        # Only recipient is [email protected] (no admins)
        self.purchased_product.invoice.send_invoice_email(send_to_admins=False,
                                                          other_recipients=['*****@*****.**'])
        # Only one in .to should be [email protected]
        self.assertEquals(len(mail.outbox[0].to), 1)
        self.assertItemsEqual(mail.outbox[0].to, ['*****@*****.**'])
Esempio n. 2
0
    def test_request_generation(self):
        cu = CompanyUserFactory(user=self.user, company=self.company)
        cu.make_purchased_microsite_admin()

        self.create_purchased_job()
        self.assertEqual(PurchasedJob.objects.all().count(), 1)
        self.assertEqual(Request.objects.all().count(), 1)
        self.assertEqual(len(mail.outbox), 1)
        self.assertItemsEqual(mail.outbox[0].from_email,
                              '*****@*****.**')
        mail.outbox = []

        # Already approved jobs should not generate an additional request.
        PurchasedJobFactory(
            owner=self.company, created_by=self.user, 
            purchased_product=self.purchased_product, is_approved=True)

        self.assertEqual(PurchasedJob.objects.all().count(), 2)
        self.assertEqual(Request.objects.all().count(), 1)
        self.assertEqual(len(mail.outbox), 0)
Esempio n. 3
0
    def setUp(self):
        super(PartnerSavedSearchFormTests, self).setUp()
        self.role.activities = self.activities
        CompanyUserFactory(user=self.user, company=self.company)
        self.partner = PartnerFactory(owner=self.company)

        self.contact = ContactFactory(user=None, email='*****@*****.**',
                                      partner=self.partner)
        self.partner_search_data = {
            'url': 'http://www.my.jobs/jobs',
            'feed': 'http://www.my.jobs/jobs/feed/rss?',
            'frequency': 'D',
            'label': 'All jobs from www.my.jobs',
            'sort_by': 'Relevance',
            'jobs_per_email': 5,
            'email': self.contact.email,
            'partner_message': "some partner message"
        }

        settings.SITE = SeoSite.objects.first()
        settings.SITE.canonical_company = self.company
        settings.SITE.save()
        # This request is only used in RequestForms, where all we care about
        # is request.user.
        self.request = RequestFactory().get(
            reverse('partner_savedsearch_save'))
        self.request.user = self.user
        self.request.impersonator = None

        form = PartnerSavedSearchForm(partner=self.partner,
                                      data=self.partner_search_data,
                                      request=self.request)
        instance = form.instance
        instance.provider = self.company
        instance.partner = self.partner
        instance.created_by = self.user
        instance.custom_message = instance.partner_message
        self.assertTrue(form.is_valid())
        self.instance = form.save()
Esempio n. 4
0
 def test_employer_user_type(self):
     """Company user type"""
     cuser = CompanyUserFactory.create()
     user = cuser.user
     self.assert_user_type('EMPLOYER', user)
Esempio n. 5
0
 def test_both(self):
     """User is both employer and staff."""
     cuser = CompanyUserFactory.create()
     user = cuser.user
     user.is_staff = True
     self.assert_user_type('EMPLOYER', user)