示例#1
0
    def setUp(self):
        super(TestGetSeriesColumn, self).setUp()
        # Create apps and contributions to index.
        self.app = amo.tests.app_factory()
        self.user = UserProfile.objects.get(username='******')
        price_tier = Price.objects.create(price='0.99')

        # Create some revenue for several different currencies.
        self.expected = [
            {'currency': 'CAD', 'count': 0},
            {'currency': 'EUR', 'count': 0},
            {'currency': 'USD', 'count': 0}
        ]
        for expected in self.expected:
            for x in range(random.randint(1, 4)):
                # Amount doesn't matter for this stat since based off of price
                # tier (USD normalized).
                Contribution.objects.create(addon_id=self.app.pk,
                                            user=self.user,
                                            amount=random.randint(0, 10),
                                            currency=expected['currency'],
                                            price_tier=price_tier)
                expected['count'] += Decimal(price_tier.price)
            expected['count'] = int(expected['count'])
        tasks.index_finance_total_by_currency([self.app.pk])
        self.refresh(timesleep=1)
示例#2
0
    def test_index(self):
        tasks.index_finance_total_by_currency([self.app.pk])
        self.refresh(timesleep=1)
        raise SkipTest('Test is unreliable and causes intermittent failures.')

        # Grab document for each source breakdown and compare.
        for currency in self.currencies:
            # For some reason, query fails if uppercase letter in filter.
            document = (Contribution.search().filter(addon=self.app.pk,
                        currency=currency.lower()).values_dict('currency',
                        'revenue', 'count', 'refunds',
                        'revenue_non_normalized')[0])
            document = {
                'count': document['count'],
                'revenue': int(document['revenue']),
                'refunds': document['refunds'],
                'revenue_non_normalized':
                    int(document['revenue_non_normalized'])}
            self.expected[currency]['revenue'] = (
                int(self.expected[currency]['revenue'])
            )
            self.expected[currency]['revenue_non_normalized'] = (
                int(self.expected[currency]['revenue_non_normalized'])
            )
            eq_(document, self.expected[currency])
示例#3
0
    def setUp(self):
        super(TestGetSeriesColumn, self).setUp()
        # Create apps and contributions to index.
        self.app = amo.tests.app_factory()
        self.user = UserProfile.objects.get(username='******')
        price_tier = Price.objects.create(price='0.99')

        # Create some revenue for several different currencies.
        self.expected = [{
            'currency': 'CAD',
            'count': 0
        }, {
            'currency': 'EUR',
            'count': 0
        }, {
            'currency': 'USD',
            'count': 0
        }]
        for expected in self.expected:
            for x in range(random.randint(1, 4)):
                # Amount doesn't matter for this stat since based off of price
                # tier (USD normalized).
                Contribution.objects.create(addon_id=self.app.pk,
                                            user=self.user,
                                            amount=random.randint(0, 10),
                                            currency=expected['currency'],
                                            price_tier=price_tier)
                expected['count'] += Decimal(price_tier.price)
            expected['count'] = int(expected['count'])
        tasks.index_finance_total_by_currency([self.app.pk])
        self.refresh(timesleep=1)
示例#4
0
    def setUp(self):
        # Create apps and contributions to index.
        self.app = amo.tests.app_factory()

        # Create a sale for each day in the expected range.
        self.expected = [
            {'currency': 'CAD', 'count': 0},
            {'currency': 'EUR', 'count': 0},
            {'currency': 'USD', 'count': 0}
        ]
        for expected in self.expected:
            for x in range(random.randint(1, 4)):
                c = Contribution.objects.create(addon_id=self.app.pk,
                                                amount=random.randint(1, 10),
                                                currency=expected['currency'])
                expected['count'] += c.amount
        tasks.index_finance_total_by_currency([self.app.pk])
        self.refresh(timesleep=1)
示例#5
0
文件: test_tasks.py 项目: vdt/zamboni
    def test_index(self):
        tasks.index_finance_total_by_currency([self.app.pk])
        self.refresh(timesleep=1)

        # Grab document for each source breakdown and compare.
        for currency in self.currencies:
            # For some reason, query fails if uppercase letter in filter.
            document = (Contribution.search().filter(
                addon=self.app.pk,
                currency=currency.lower()).values_dict('currency', 'revenue',
                                                       'count', 'refunds')[0])
            document = {
                'count': document['count'],
                'revenue': int(document['revenue']),
                'refunds': document['refunds']
            }
            self.expected[currency]['revenue'] = (int(
                self.expected[currency]['revenue']))
            eq_(document, self.expected[currency])
示例#6
0
    def test_index(self):
        tasks.index_finance_total_by_currency([self.app.pk])
        self.refresh(timesleep=1)

        # Grab document for each source breakdown and compare.
        for currency in self.currencies:
            # For some reason, query fails if uppercase letter in filter.
            document = (
                Contribution.search()
                .filter(addon=self.app.pk, currency=currency.lower())
                .values_dict("currency", "revenue", "count", "refunds", "revenue_non_normalized")[0]
            )
            document = {
                "count": document["count"],
                "revenue": int(document["revenue"]),
                "refunds": document["refunds"],
                "revenue_non_normalized": int(document["revenue_non_normalized"]),
            }
            self.expected[currency]["revenue"] = int(self.expected[currency]["revenue"])
            self.expected[currency]["revenue_non_normalized"] = int(self.expected[currency]["revenue_non_normalized"])
            eq_(document, self.expected[currency])
示例#7
0
    def setUp(self):
        # Create apps and contributions to index.
        self.app = amo.tests.app_factory()
        price_tier = Price.objects.create(price=.99)

        # Create some revenue for several different currencies.
        self.expected = [
            {'currency': 'CAD', 'count': 0},
            {'currency': 'EUR', 'count': 0},
            {'currency': 'USD', 'count': 0}
        ]
        for expected in self.expected:
            for x in range(random.randint(1, 4)):
                # Amount doesn't matter for this stat since based off of price
                # tier (USD normalized).
                Contribution.objects.create(addon_id=self.app.pk,
                                            amount=random.randint(0, 10),
                                            currency=expected['currency'],
                                            price_tier=price_tier)
                expected['count'] += cut(price_tier.price)
            expected['count'] = int(expected['count'])
        tasks.index_finance_total_by_currency([self.app.pk])
        self.refresh(timesleep=1)
示例#8
0
    def setUp(self):
        # Create apps and contributions to index.
        self.app = amo.tests.app_factory()

        # Create a sale for each day in the expected range.
        self.expected = [{
            'currency': 'CAD',
            'count': 0
        }, {
            'currency': 'EUR',
            'count': 0
        }, {
            'currency': 'USD',
            'count': 0
        }]
        for expected in self.expected:
            for x in range(random.randint(1, 4)):
                c = Contribution.objects.create(addon_id=self.app.pk,
                                                amount=random.randint(1, 10),
                                                currency=expected['currency'])
                expected['count'] += c.amount
        tasks.index_finance_total_by_currency([self.app.pk])
        self.refresh(timesleep=1)