Our ES tests are rotting; this fixes decimal usage

This commit is contained in:
Kumar McMillan 2012-08-15 10:17:22 -05:00
Родитель 3f66909b8f
Коммит a9783f1edc
2 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -19,7 +19,7 @@ class BaseTaskTest(amo.tests.ESTestCase):
def baseSetUp(self): def baseSetUp(self):
self.app = amo.tests.app_factory() self.app = amo.tests.app_factory()
self.usd_price = .99 self.usd_price = '0.99'
self.price_tier = Price.objects.create(price=self.usd_price) self.price_tier = Price.objects.create(price=self.usd_price)
self.inapp = InappConfig.objects.create( self.inapp = InappConfig.objects.create(
@ -463,7 +463,7 @@ class TestAlreadyIndexed(BaseTaskTest):
self.ids = [] self.ids = []
self.expected = {'addon': self.app.pk, self.expected = {'addon': self.app.pk,
'date': date, 'date': date,
'revenue': 0, 'count': 3, 'revenue': Decimal('0'), 'count': 3,
'refunds': 1} 'refunds': 1}
for x in range(self.expected['count']): for x in range(self.expected['count']):
@ -473,12 +473,12 @@ class TestAlreadyIndexed(BaseTaskTest):
price_tier=self.price_tier) price_tier=self.price_tier)
self.refresh(timesleep=1) self.refresh(timesleep=1)
self.ids.append(c.id) self.ids.append(c.id)
self.expected['revenue'] += self.usd_price self.expected['revenue'] += Decimal(self.usd_price)
c.update(uuid=123) c.update(uuid=123)
Refund.objects.create(contribution=c, Refund.objects.create(contribution=c,
status=amo.REFUND_APPROVED) status=amo.REFUND_APPROVED)
self.expected['revenue'] -= self.usd_price self.expected['revenue'] -= Decimal(self.usd_price)
self.expected['count'] -= 1 self.expected['count'] -= 1
self.expected['revenue'] = cut(self.expected['revenue']) self.expected['revenue'] = cut(self.expected['revenue'])

Просмотреть файл

@ -232,7 +232,7 @@ class TestGetSeriesLine(amo.tests.ESTestCase):
def setUp(self): def setUp(self):
# Create apps and contributions to index. # Create apps and contributions to index.
self.app = amo.tests.app_factory() self.app = amo.tests.app_factory()
price_tier = Price.objects.create(price=.99) price_tier = Price.objects.create(price='0.99')
# Create a sale for each day in the expected range. # Create a sale for each day in the expected range.
self.expected_days = (1, 2, 3, 4, 5) self.expected_days = (1, 2, 3, 4, 5)
@ -240,7 +240,7 @@ class TestGetSeriesLine(amo.tests.ESTestCase):
# Create different amounts of contribs for each day. # Create different amounts of contribs for each day.
for x in range(0, day): for x in range(0, day):
c = Contribution.objects.create(addon_id=self.app.pk, c = Contribution.objects.create(addon_id=self.app.pk,
amount=.99, amount='0.99',
price_tier=price_tier, price_tier=price_tier,
type=amo.CONTRIB_PURCHASE) type=amo.CONTRIB_PURCHASE)
c.update(created=datetime.datetime(2012, 5, day, 0, 0, 0)) c.update(created=datetime.datetime(2012, 5, day, 0, 0, 0))
@ -288,7 +288,7 @@ class TestGetSeriesColumn(amo.tests.ESTestCase):
def setUp(self): def setUp(self):
# Create apps and contributions to index. # Create apps and contributions to index.
self.app = amo.tests.app_factory() self.app = amo.tests.app_factory()
price_tier = Price.objects.create(price=.99) price_tier = Price.objects.create(price='0.99')
# Create some revenue for several different currencies. # Create some revenue for several different currencies.
self.expected = [ self.expected = [