class TestQPClient(object): def setup(self): self.client = QPClient('foobar') self.api = self.client.api self.api.perform = MagicMock() def test_api_instance(self): assert isinstance(self.client.api, QPApi) def test_get_delegation(self): self.client.get("/dummy") self.api.perform.assert_called_once_with("get", "/dummy") def test_post_delegation(self): self.client.post("/dummy") self.api.perform.assert_called_once_with("post", "/dummy") def test_delete_delegation(self): self.client.delete("/dummy") self.api.perform.assert_called_once_with("delete", "/dummy") def test_put_delegation(self): self.client.put("/dummy") self.api.perform.assert_called_once_with("put", "/dummy") def test_patch_delegation(self): self.client.patch("/dummy") self.api.perform.assert_called_once_with("patch", "/dummy") def test_non_http_method(self): def request_foobar(client, path): return self.client.foobar(path) assert_raises(AttributeError, request_foobar, self.client, "/dummy")
def update_status(self): client = QPClient(f":{settings.QUICKPAY_API_KEY}") # get payment id from order id transaction = client.get(f"/payments/{self.transaction_id}") if transaction["state"] == "processed" and transaction["accepted"]: self.payment.set_confirmed() if transaction["state"] == "new" and transaction["accepted"]: self.payment.set_accepted() if transaction["state"] == "rejected" and not transaction["accepted"]: self.payment.set_rejected(repr(transaction))
def update_status(self): client = QPClient(":{0}".format(settings.QUICKPAY_API_KEY)) # get payment id from order id transactions = client.get('/payments', order_id=self.order_id) if(len(transactions) > 0): transaction = transactions[0] if transaction['state'] == 'processed' and transaction['accepted']: self.payment.set_confirmed() if transaction['state'] == 'rejected' and not transaction['accepted']: self.payment.set_rejected(repr(transaction))
def update_status(self): client = QPClient(":{0}".format(settings.QUICKPAY_API_KEY)) # get payment id from order id transactions = client.get("/payments", order_id=self.order_id) if len(transactions) > 0: transaction = transactions[0] if transaction["state"] == "processed" and transaction["accepted"]: self.payment.set_confirmed() if transaction["state"] == "rejected" and not transaction["accepted"]: self.payment.set_rejected(repr(transaction))
def update_status(self): client = QPClient(":{0}".format(settings.QUICKPAY_API_KEY)) # get payment id from order id transactions = client.get("/payments", order_id=self.order_id) if len(transactions) > 0: transaction = transactions[0] if transaction["state"] == "processed" and transaction["accepted"]: self.payment.set_confirmed() if transaction[ "state"] == "rejected" and not transaction["accepted"]: self.payment.set_rejected(repr(transaction))