Exemplo n.º 1
0
    def test_functionality_case_premium(self):

        data = {}
        data["creditcardnumber"] = "4024007129931746"
        data["cardholder"] = "John Doe"
        data["expirationdate"] = datetime.date(2021,6,5)
        data["securitycode"] = "043"
        data["amount"] = 501

        payment = PaymentForm(data)
        payment = payment.save()
        payment = model_to_dict(payment)

        name, status = Dispatcher.dispatch(payment)

        self.assertEqual(status, HTTPStatus.OK)
        self.assertEqual(name, Dispatcher.premium_gateway.name)
Exemplo n.º 2
0
    def test_functionality_case_unavailable_cheap(self):

        data = {}
        data["creditcardnumber"] = "4024007129931746"
        data["cardholder"] = "John Doe"
        data["expirationdate"] = datetime.date(2021,6,5)
        data["securitycode"] = "043"
        data["amount"] = 15

        payment = PaymentForm(data)
        payment = payment.save()
        payment = model_to_dict(payment)

        Dispatcher.cheap_gateway = CheapGateway(False)

        name, status = Dispatcher.dispatch(payment)

        self.assertEqual(status, HTTPStatus.TOO_MANY_REQUESTS)
        self.assertEqual(name, Dispatcher.cheap_gateway.name)