-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
81 lines (62 loc) · 3.36 KB
/
tests.py
File metadata and controls
81 lines (62 loc) · 3.36 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
import unittest
from subscrypt import Subscrypt
import json
with open('config.json', 'r') as f:
config = json.load(f)
class TestSubscrypt(unittest.TestCase):
def setUp(self):
self.client = Subscrypt()
def test_is_connected_returns_true(self):
self.assertEqual(self.client.is_connected(), True)
def test_check_subscription_returns_bool(self):
self.assertIn(
self.client.check_subscription(config['test']['userAddress'], config['test']['providerAddress'], 0),
[True, False])
def test_check_subscription_with_username_returns_bool(self):
self.assertIn(
self.client.check_subscription(config['test']['username'], config['test']['providerAddress'], 0),
[True, False])
def test_get_username_works(self):
self.assertEqual(self.client.get_username(config['test']['userAddress']), config['test']['username'])
def test_retrieve_whole_data_with_username_works(self):
self.assertIsNotNone(self.client.retrieve_whole_data_with_username(
config['test']['username'], config['test']['passWord']))
def test_retrieve_data_with_username_works(self):
self.assertIsNotNone(self.client.retrieve_data_with_username(
config['test']['username'], config['test']['providerAddress'], config['test']['passWord']))
def test_is_username_available_returns_false(self):
self.assertEqual(self.client.is_username_available(config['test']['username']), False)
def test_check_auth_true(self):
self.assertEqual(self.client.check_auth(config['test']['userAddress'], config['test']['providerAddress'],
config['test']['passWord']), True)
def test_check_auth_with_username_true(self):
self.assertEqual(
self.client.check_auth_with_username(config['test']['username'], config['test']['providerAddress'],
config['test']['passWord']), True)
def test_user_check_auth_with_username_true(self):
self.assertEqual(
self.client.user_check_auth_with_username(config['test']['username'],
config['test']['passWord']), True)
def test_get_plan_data(self):
plans = config['test']['plansData']
index = 0
for plan in plans:
self.assertEqual(
self.client.get_plan_data(config['test']['providerAddress'],
index), plan)
index += 1
def test_provider_check_auth_true(self):
self.assertEqual(
self.client.provider_check_auth(config['test']['providerAddress'],
config['test']['passWord']), True)
def test_provider_check_auth_with_username_true(self):
self.assertEqual(
self.client.provider_check_auth_with_username(config['test']['providerUsername'],
config['test']['passWord']), True)
def test_get_plan_data(self):
for i in range(len(config['test']['plansData'])):
self.assertEqual(
self.client.get_plan_characteristics(config['test']['providerAddress'],
i), config['test']['plansCharacteristic'][i])
if __name__ == '__main__':
unittest.main()