示例#1
0
    def test_start_boku_transaction_with_valid_data(self):
        form = BokuTransactionForm(self.post_data)
        ok_(form.is_valid(), form.errors)

        transaction = form.start_transaction()
        ok_('transaction_id' in transaction, transaction)
        ok_('buy_url' in transaction, transaction)
示例#2
0
    def test_start_boku_transaction_with_valid_data(self):
        form = BokuTransactionForm(self.post_data)
        ok_(form.is_valid(), form.errors)

        transaction = form.start_transaction()
        ok_('transaction_id' in transaction, transaction)
        ok_('buy_url' in transaction, transaction)
示例#3
0
文件: views.py 项目: oremj/solitude
    def post(self, request):
        form = BokuTransactionForm(request.POST)

        if form.is_valid():
            transaction = form.start_transaction()
            log.error(('Successfully started Boku Transaction: '
                       '{transaction_id}').format(
                transaction_id=transaction['transaction_id'],
            ))
            return Response(transaction)
        else:
            log.error('Failed to start Boku Transaction: {errors}'.format(
                errors=form.errors,
            ))
            return self.form_errors(form)
示例#4
0
    def post(self, request):
        form = BokuTransactionForm(request.DATA)

        if form.is_valid():
            transaction = form.start_transaction()
            log.info(('Successfully started Boku Transaction: '
                      '{transaction_id}').format(
                transaction_id=transaction['transaction_id'],
            ))
            return Response(transaction)
        else:
            log.error('Failed to start Boku Transaction: {errors}'.format(
                errors=form.errors.as_text(),
            ))
            return self.form_errors(form)
示例#5
0
 def test_seller_uuid_requires_a_boku_seller(self):
     self.seller_boku.delete()
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('seller_uuid' in form.errors)
示例#6
0
 def test_seller_uuid_requires_an_existing_seller(self):
     self.post_data['seller_uuid'] = 'foo'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('seller_uuid' in form.errors)
示例#7
0
 def test_price_requires_an_existing_boku_price_tier(self):
     self.post_data['price'] = '1.00'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_(form.ERROR_BAD_PRICE in form.errors['__all__'])
示例#8
0
 def test_price_requires_a_decimal_value(self):
     self.post_data['price'] = 'foo'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('price' in form.errors)
示例#9
0
 def test_country_requires_a_defined_country_code(self):
     self.post_data['country'] = 'foo'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('country' in form.errors)
示例#10
0
 def test_callback_url_requires_a_valid_url(self):
     self.post_data['callback_url'] = 'foo'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('callback_url' in form.errors, form.errors)
示例#11
0
 def test_forward_url_requires_a_valid_url(self):
     self.post_data['forward_url'] = 'not-a-url'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('forward_url' in form.errors, form.errors)
示例#12
0
 def test_forward_url_requires_a_valid_url(self):
     self.post_data['forward_url'] = 'not-a-url'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('forward_url' in form.errors, form.errors)
示例#13
0
    def test_boku_failure_raises_BokuException(self):
        form = BokuTransactionForm(self.post_data)
        ok_(form.is_valid(), form.errors)

        with mock.patch('lib.boku.client.mocks', {'prepare': (500, '')}):
            assert_raises(BokuException, form.start_transaction)
示例#14
0
 def test_seller_uuid_requires_a_boku_seller(self):
     self.seller_boku.delete()
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('seller_uuid' in form.errors)
示例#15
0
 def test_seller_uuid_requires_an_existing_seller(self):
     self.post_data['seller_uuid'] = 'foo'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('seller_uuid' in form.errors)
示例#16
0
 def test_price_requires_an_existing_boku_price_tier(self):
     self.post_data['price'] = '1.00'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_(form.ERROR_BAD_PRICE in form.errors['__all__'])
示例#17
0
 def test_price_requires_a_decimal_value(self):
     self.post_data['price'] = 'foo'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('price' in form.errors)
示例#18
0
 def test_country_requires_a_defined_country_code(self):
     self.post_data['country'] = 'foo'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('country' in form.errors)
示例#19
0
    def test_boku_failure_raises_BokuException(self):
        form = BokuTransactionForm(self.post_data)
        ok_(form.is_valid(), form.errors)

        with mock.patch('lib.boku.client.mocks', {'prepare': (500, '')}):
            assert_raises(BokuException, form.start_transaction)
示例#20
0
 def test_currency_must_be_valid(self):
     self.post_data['currency'] = 'CDN'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('currency' in form.errors)
示例#21
0
 def test_callback_url_requires_a_valid_url(self):
     self.post_data['callback_url'] = 'foo'
     form = BokuTransactionForm(self.post_data)
     ok_(not form.is_valid(), form.errors)
     ok_('callback_url' in form.errors, form.errors)