-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Simple Tests - Patched some methods (Nothing major)
- Loading branch information
1 parent
4e03df9
commit f35b37b
Showing
6 changed files
with
145 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import random | ||
import string | ||
|
||
from python_flutterwave import payment | ||
import unittest | ||
|
||
|
||
class TestStandardPayment(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
self.token = "YOUR_SECRET_KEY" | ||
self.tx_ref = f"{''.join(random.choice(string.ascii_letters) for i in range(10))}" | ||
self.amount = 10.0 | ||
self.currency = 'KES' | ||
self.redirect_url = "https://example.com/" | ||
self.payment_options = "mpesa" | ||
self.customer_email = "[email protected]" | ||
self.customer_phone_number = "1234567890" | ||
self.customer_name = "John Doe" | ||
self.title = "Test Payment" | ||
self.description = "Just pay me..." | ||
payment.token = self.token | ||
self.link = payment.initiate_payment(tx_ref=self.tx_ref, amount=self.amount, redirect_url=self.redirect_url, | ||
payment_options=self.payment_options, customer_email=self.customer_email, | ||
customer_phone_number=self.customer_phone_number, | ||
customer_name=self.customer_name, title=self.title, | ||
description=self.description, currency=self.currency) | ||
|
||
def tearDown(self) -> None: | ||
pass | ||
|
||
def test_argument_types(self): | ||
self.assertIsInstance(self.token, str) | ||
self.assertIsInstance(self.tx_ref, str) | ||
self.assertIsInstance(self.amount, float) | ||
self.assertIsInstance(self.currency, str) | ||
self.assertIsInstance(self.redirect_url, str) | ||
self.assertIsInstance(self.payment_options, str) | ||
self.assertIsInstance(self.customer_email, str) | ||
self.assertIsInstance(self.customer_phone_number, str) | ||
self.assertIsInstance(self.customer_name, str) | ||
self.assertIsInstance(self.title, str) | ||
self.assertIsInstance(self.description, str) | ||
|
||
def test_mandatory_args(self): | ||
self.assertIsNot(self.token, "") | ||
self.assertIsNot(self.amount, "") | ||
self.assertIsNot(self.customer_email, "") | ||
|
||
def test_return_obj(self): | ||
self.assertIsInstance(self.link, str) | ||
self.assertIsNotNone(self.link) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import unittest | ||
import random | ||
import string | ||
|
||
from python_flutterwave import payment | ||
|
||
|
||
class TestInitiateUSSDPayment(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
self.token = "YOUR_SECRET_KEY" | ||
self.tx_ref = f"{''.join(random.choice(string.ascii_letters) for i in range(10))}" | ||
self.amount = 10.0 | ||
self.account_bank = "044" | ||
self.email = "[email protected]" | ||
self.phone_number = "1234567890" | ||
self.full_name = "John Doe" | ||
payment.token = self.token | ||
self.details = payment.initiate_ussd_payment(tx_ref=self.tx_ref, amount=self.amount, | ||
email=self.email, phone_number=self.phone_number, | ||
full_name=self.full_name, account_bank=self.account_bank) | ||
|
||
def tearDown(self) -> None: | ||
pass | ||
|
||
def test_argument_types(self): | ||
self.assertIsInstance(self.token, str) | ||
self.assertIsInstance(self.tx_ref, str) | ||
self.assertIsInstance(self.amount, float) | ||
self.assertIsInstance(self.account_bank, str) | ||
|
||
def test_mandatory_args(self): | ||
self.assertIsNot(self.token, "") | ||
self.assertIsNot(self.amount, "") | ||
self.assertIsNot(self.email, "") | ||
self.assertIsNot(self.account_bank, "") | ||
self.assertIsNot(self.phone_number, "") | ||
|
||
def test_return_obj(self): | ||
self.assertIsInstance(self.details, dict) | ||
self.assertIsNotNone(self.details) | ||
self.assertIn("status", self.details.keys()) | ||
self.assertIn("message", self.details.keys()) | ||
self.assertIn("data", self.details.keys()) | ||
self.assertIn("meta", self.details.keys()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import random | ||
import string | ||
import unittest | ||
|
||
from python_flutterwave import payment | ||
|
||
|
||
class TestTriggerMpesaPayment(unittest.TestCase): | ||
|
||
def setUp(self) -> None: | ||
self.token = "YOUR_SECRET_KEY" | ||
self.tx_ref = f"{''.join(random.choice(string.ascii_letters) for i in range(10))}" | ||
self.amount = 10.0 | ||
self.currency = 'KES' | ||
self.email = "[email protected]" | ||
self.phone_number = "1234567890" | ||
self.full_name = "John Doe" | ||
payment.token = self.token | ||
self.details = payment.trigger_mpesa_payment(tx_ref=self.tx_ref, amount=self.amount, currency=self.currency, | ||
email=self.email, phone_number=self.phone_number, | ||
full_name=self.full_name) | ||
|
||
def tearDown(self) -> None: | ||
pass | ||
|
||
def test_argument_types(self): | ||
self.assertIsInstance(self.token, str) | ||
self.assertIsInstance(self.tx_ref, str) | ||
self.assertIsInstance(self.amount, float) | ||
self.assertIsInstance(self.currency, str) | ||
|
||
def test_mandatory_args(self): | ||
self.assertIsNot(self.token, "") | ||
self.assertIsNot(self.amount, "") | ||
self.assertIsNot(self.email, "") | ||
|
||
def test_return_obj(self): | ||
self.assertIsInstance(self.details, dict) | ||
self.assertIsNotNone(self.details) | ||
self.assertIn("status", self.details.keys()) | ||
self.assertIn("message", self.details.keys()) | ||
self.assertIn("data", self.details.keys()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = python-flutterwave | ||
version = 0.2.6 | ||
version = 0.2.7 | ||
author = William Otieno | ||
author_email = [email protected] | ||
description = Python Wrapper for interacting with the Flutterwave Payments API | ||
|