This repository has been archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_gtbmm.py
68 lines (50 loc) · 2.14 KB
/
test_gtbmm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
from gtbmm import GTBMobileMoney
from gtbmm.exceptions import EXCEPTIONS_MAP
import pytest
def test_auth():
# Test proper authentication
mm = GTBMobileMoney(os.environ['GTB_ACCOUNT'], os.environ['GTB_PIN'])
assert mm.auth() is True
# Test Incorrect Pin
with pytest.raises(EXCEPTIONS_MAP['29']) as exc:
mm.auth(os.environ['GTB_ACCOUNT'], '0000')
assert exc.value.message == 'Incorrect PIN'
# Test Invalid Account
with pytest.raises(EXCEPTIONS_MAP['11']) as exc:
mm.auth('1111', '1111')
assert exc.value.message == 'Invalid Account'
def test_balance():
mm = GTBMobileMoney(os.environ['GTB_ACCOUNT'], os.environ['GTB_PIN'])
response = mm.balance()
assert response.get('balance') >= 0
def test_history():
mm = GTBMobileMoney(os.environ['GTB_ACCOUNT'], os.environ['GTB_PIN'])
history = list(mm.history())
assert len(history) > 0
def test_send():
mm = GTBMobileMoney(os.environ['GTB_ACCOUNT'], os.environ['GTB_PIN'])
# Test sending an invalid amount
with pytest.raises(EXCEPTIONS_MAP['212']):
mm._beforeSend(os.environ['GTB_DST_ACCOUNT'], 0)
# Test sending to an invalid destination account
with pytest.raises(EXCEPTIONS_MAP['2020']):
mm._beforeSend('08012345', '10')
# Test sending to an inactive destination account
with pytest.raises(EXCEPTIONS_MAP['128']):
mm._beforeSend('08012345678', '10')
# Test sending to an incorrect destination account
with pytest.raises(EXCEPTIONS_MAP['687']):
mm._beforeSend('08033333333', '10')
# Test sending less than the minimum amount
with pytest.raises(EXCEPTIONS_MAP['107']):
mm._beforeSend(os.environ['GTB_DST_ACCOUNT'], '1')
# Test sending with insufficient balance
with pytest.raises(EXCEPTIONS_MAP['16']):
mm._beforeSend(os.environ['GTB_DST_ACCOUNT'], '999')
# Test sending with more than maximum allowed
with pytest.raises(EXCEPTIONS_MAP['106']):
mm._beforeSend(os.environ['GTB_DST_ACCOUNT'], '100000')
# Test sending to self
with pytest.raises(EXCEPTIONS_MAP['295']):
mm._beforeSend(os.environ['GTB_ACCOUNT'], '50')