-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.py
48 lines (41 loc) · 1.13 KB
/
tests.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
import unittest
import api
class TestURLs(unittest.TestCase):
api = None
def setUp(self):
self.api = api.Api('base_url')
self.api.update_endpoints(
{
'a': 'endpoint',
'b': 'b%(replace)sd',
'c': None,
None: 'd'
}
)
def testEndPointCompletion(self):
expected = 'base_url/endpoint'
actual = self.api._url('a')
self.assertEqual(
actual,
expected,
"The basic end point completion did not work"
)
def testShouldRaiseNoEndpointFound(self):
expected = api.EndPointDoesNotExist
actual = lambda : self.api._url('DNE')
self.assertRaises(
expected,
actual,
)
def testURLData(self):
expected = 'base_url/b3d'
actual = self.api._url('b', {'replace': 3})
self.assertEqual(
actual,
expected,
"End Point Completion did not work with URL Data"
)
def tearDown(self):
self.api = None
if __name__ == '__main__':
unittest.main()