Skip to content

Commit ed694ba

Browse files
committed
Add simple Balance test for demonstration
1 parent 2c5dd2d commit ed694ba

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

tests/__init__.py

Whitespace-only changes.

tests/test_balance.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import unittest
2+
from messagebird import Client
3+
4+
try:
5+
from unittest.mock import Mock
6+
except ImportError:
7+
# mock was added to unittest in Python 3.3, but was an external library
8+
# before.
9+
from mock import Mock
10+
11+
12+
class TestBalance(unittest.TestCase):
13+
14+
def test_balance(self):
15+
http_client = Mock()
16+
http_client.request.return_value = '{"payment": "prepaid","type": "credits","amount": 9.2}'
17+
18+
balance = Client('', http_client).balance()
19+
20+
http_client.request.assert_called_once_with('balance', 'GET', None)
21+
22+
self.assertEqual('prepaid', balance.payment)
23+
self.assertEqual('credits', balance.type)

0 commit comments

Comments
 (0)