Пример #1
0
def test_retrieve_saved_tokens_with_customer(django_user_model):
    """Tests that function works with customer alone."""
    # Create user and login
    django_user_1 = django_user_model.objects.create_user(username='******',
                                                          password='******')
    django_user_2 = django_user_model.objects.create_user(username='******',
                                                          password='******')

    # Create tokens
    create_token(django_user_1, '1', 'abcdefghijklmnopqrstuvw', '11114444')
    create_token(django_user_1, '1', 'zyxwvutsrqponmlkjihgfed', '99996666')
    create_token(None, '1', 'ccccccccccccccccccccccc', '77778888')
    create_token(django_user_1, '2', 'bbbbbbbbbbbbbbbbbbbbbbb', '55556666')
    create_token(django_user_2, '3', 'aaaaaaaaaaaaaaaaaaaaaaa', '22222222')

    # Retrieve tokens
    tokens = bridge_oscar.retrieve_saved_tokens(customer_code='1')

    assert len(tokens) == 3
    assert tokens[0].customer_code == '1'
    assert tokens[1].customer_code == '1'
    assert tokens[2].customer_code == '1'
    assert tokens[0].token_f4l4 in ('11114444', '99996666', '77778888')
    assert tokens[1].token_f4l4 in ('11114444', '99996666', '77778888')
    assert tokens[2].token_f4l4 in ('11114444', '99996666', '77778888')
    assert tokens[0].token_f4l4 != tokens[1].token_f4l4
    assert tokens[0].token_f4l4 != tokens[2].token_f4l4
    assert tokens[1].token_f4l4 != tokens[2].token_f4l4
Пример #2
0
    def get_context_data(self, **kwargs):
        """Add additional data for payment processing."""
        context = super(PaymentDetailsView, self).get_context_data(**kwargs)

        # Add the credit card data
        context['bankcard_form'] = kwargs.get(
            'bankcard_form', oscar_payment_forms.BankcardForm())

        # Add the billing address data
        context['billing_address_form'] = kwargs.get(
            'billing_address_form', custom_forms.BillingAddressForm())

        # Add details regarding saved credit card tokens
        context['token_vault'] = bridge_oscar.SETTINGS['enable_token_vault']
        context['saved_tokens'] = bridge_oscar.retrieve_saved_tokens(
            self.request.user)

        return context
Пример #3
0
def test_retrieve_saved_tokens_with_nothing(django_user_model):
    """Tests that function returns empty queryset with no arguments."""
    # Create user and login
    django_user_1 = django_user_model.objects.create_user(username='******',
                                                          password='******')
    django_user_2 = django_user_model.objects.create_user(username='******',
                                                          password='******')

    # Create tokens
    create_token(django_user_1, '1', 'abcdefghijklmnopqrstuvw', '11114444')
    create_token(django_user_1, '1', 'zyxwvutsrqponmlkjihgfed', '99996666')
    create_token(django_user_1, '2', 'bbbbbbbbbbbbbbbbbbbbbbb', '55556666')
    create_token(django_user_2, '3', 'aaaaaaaaaaaaaaaaaaaaaaa', '22222222')

    # Retrieve tokens
    tokens = bridge_oscar.retrieve_saved_tokens()

    assert bool(tokens) is False
    assert list(tokens) == list(models.HelcimToken.objects.none())
def test_retrieve_saved_tokens_valid(django_user_model):
    """Tests that retrieve_saved_tokens retrieves tokens properly."""
    # Create user and login
    django_user_1 = django_user_model.objects.create_user(
        username='******', password='******'
    )
    django_user_2 = django_user_model.objects.create_user(
        username='******', password='******'
    )

    # Create tokens
    create_token(django_user_1, '1', 'abcdefghijklmnopqrstuvw', '11114444')
    create_token(django_user_1, '1', 'zyxwvutsrqponmlkjihgfed', '99996666')
    create_token(django_user_2, '2', 'aaaaaaaaaaaaaaaaaaaaaaa', '22222222')

    # Retrieve tokens
    tokens = bridge_oscar.retrieve_saved_tokens(django_user_1)

    assert len(tokens) == 2
    assert tokens[0].customer_code == '1'
    assert tokens[1].customer_code == '1'
    assert tokens[0].token_f4l4 in ('11114444', '99996666')
    assert tokens[1].token_f4l4 in ('11114444', '99996666')
    assert tokens[0].token_f4l4 != tokens[1].token_f4l4
Пример #5
0
def test_retrieve_saved_tokens_shortcut():
    """Tests that retrieve_saved_tokens shortcut works."""
    token_details = bridge_oscar.retrieve_saved_tokens(customer_code='1')

    assert token_details['customer_code'] == '1'