Пример #1
0
 def test_get_refund_amount_when_zero(self):
     """
     Assert that correct value is returned when existing refund_amount is
     zero.
     """
     campaign = MagicMock(spec=('total_budget_dollars',))
     campaign.total_budget_dollars = 200.
     refund_amount = get_refund_amount(campaign, self.billable_amount)
     self.assertEquals(refund_amount,
         campaign.total_budget_dollars - self.billable_amount)
Пример #2
0
 def POST_refund_campaign(self, form, jquery, link, campaign):
     billable_impressions = promote.get_billable_impressions(campaign)
     billable_amount = promote.get_billable_amount(campaign,
                                                   billable_impressions)
     refund_amount = promote.get_refund_amount(campaign, billable_amount)
     if refund_amount > 0:
         promote.refund_campaign(link, campaign, billable_amount,
                                 billable_impressions)
         form.set_html('.status', _('refund succeeded'))
     else:
         form.set_html('.status', _('refund not needed'))
Пример #3
0
 def POST_refund_campaign(self, form, jquery, link, campaign):
     billable_impressions = promote.get_billable_impressions(campaign)
     billable_amount = promote.get_billable_amount(campaign,
                                                   billable_impressions)
     refund_amount = promote.get_refund_amount(campaign, billable_amount)
     if refund_amount > 0:
         promote.refund_campaign(link, campaign, billable_amount,
                                 billable_impressions)
         form.set_html('.status', _('refund succeeded'))
     else:
         form.set_html('.status', _('refund not needed'))
Пример #4
0
    def POST_refund_campaign(self, form, jquery, link, campaign):
        if not link or not campaign or link._id != campaign.link_id:
            return abort(404, "not found")

        billable_impressions = promote.get_billable_impressions(campaign)
        billable_amount = promote.get_billable_amount(campaign, billable_impressions)
        refund_amount = promote.get_refund_amount(campaign, billable_amount)
        if refund_amount > 0:
            promote.refund_campaign(link, campaign, billable_amount, billable_impressions)
            form.set_html(".status", _("refund succeeded"))
        else:
            form.set_html(".status", _("refund not needed"))
Пример #5
0
    def POST_refund_campaign(self, form, jquery, link, campaign):
        if not link or not campaign or link._id != campaign.link_id:
            return abort(404, 'not found')

        billable_impressions = promote.get_billable_impressions(campaign)
        billable_amount = promote.get_billable_amount(campaign,
                                                      billable_impressions)
        refund_amount = promote.get_refund_amount(campaign, billable_amount)
        if refund_amount > 0:
            promote.refund_campaign(link, campaign, billable_amount,
                                    billable_impressions)
            form.set_text('.status', _('refund succeeded'))
        else:
            form.set_text('.status', _('refund not needed'))
Пример #6
0
    def test_get_refund_amount_rounding(self):
        """Assert that inputs are correctly rounded up to the nearest penny."""
        # If campaign.refund_amount is less than a fraction of a penny,
        # the refund_amount should be campaign.total_budget_dollars.
        self.campaign.refund_amount = 0.00000001
        refund_amount = get_refund_amount(self.campaign, self.billable_amount)
        self.assertEquals(refund_amount, self.billable_amount)

        self.campaign.refund_amount = 0.00999999
        refund_amount = get_refund_amount(self.campaign, self.billable_amount)
        self.assertEquals(refund_amount, self.billable_amount)

        # If campaign.refund_amount is just slightly more than a penny,
        # the refund amount should be campaign.total_budget_dollars - 0.01.
        self.campaign.refund_amount = 0.01000001
        refund_amount = get_refund_amount(self.campaign, self.billable_amount)
        self.assertEquals(refund_amount, self.billable_amount - 0.01)

        # Even if campaign.refund_amount is just barely short of two pennies,
        # the refund amount should be campaign.total_budget_dollars - 0.01.
        self.campaign.refund_amount = 0.01999999
        refund_amount = get_refund_amount(self.campaign, self.billable_amount)
        self.assertEquals(refund_amount, self.billable_amount - 0.01)