-
Notifications
You must be signed in to change notification settings - Fork 0
/
uniturl.py
49 lines (39 loc) · 4.53 KB
/
uniturl.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
import unittest
from bots.botslib import Uri
'''no plugin
'''
class TestTranslate(unittest.TestCase):
def setUp(self):
pass
def testcombinations(self):
self.assertEqual('scheme://username:password@hostname:80/path1/path2/filename',str(Uri(scheme='scheme',username='username',password='password',hostname='hostname',port=80,path='path1/path2',filename= 'filename',query={'query':'argument'},fragment='fragment')),'basis')
self.assertEqual('scheme://username:password@hostname:80/path1/path2/filename',str(Uri(scheme='scheme',username='username',password='password',hostname='hostname',port=80,path='path1/path2',filename= 'filename')),'basis')
self.assertEqual('scheme:/path1/path2/filename',str(Uri(scheme='scheme',path='/path1/path2',filename='filename')),'')
self.assertEqual('scheme:path1/path2/filename',str(Uri(scheme='scheme',path='path1/path2',filename='filename')),'')
self.assertEqual('path1/path2/filename',str(Uri(path='path1/path2',filename='filename')),'')
self.assertEqual('path1/path2/',str(Uri(path='path1/path2')),'')
self.assertEqual('filename',str(Uri(filename='filename')),'')
self.assertEqual('scheme:path1/path2/',str(Uri(scheme='scheme',path='path1/path2')),'')
self.assertEqual('scheme:filename',str(Uri(scheme='scheme',filename='filename')),'')
self.assertEqual('scheme://username:password@hostname:80/path1/path2/',str(Uri(scheme='scheme',username='username',password='password',hostname='hostname',port=80,path='path1/path2')),'basis')
self.assertEqual('scheme://username:password@hostname:80/filename',str(Uri(scheme='scheme',username='username',password='password',hostname='hostname',port=80,filename= 'filename')),'basis')
self.assertEqual('scheme://username:password@hostname:80',str(Uri(scheme='scheme',username='username',password='password',hostname='hostname',port=80)),'bas')
self.assertEqual('scheme://username:password@hostname',str(Uri(scheme='scheme',username='username',password='password',hostname='hostname')),'bas')
self.assertEqual('scheme://username@hostname',str(Uri(scheme='scheme',username='username',hostname='hostname')),'bas')
self.assertEqual('scheme://hostname',str(Uri(scheme='scheme',hostname='hostname')),'bas')
self.assertEqual('scheme://username@hostname:80/path1/path2/filename',str(Uri(scheme='scheme',username='username',hostname='hostname',port=80,path='path1/path2',filename= 'filename')),'no password')
self.assertEqual('scheme://hostname:80/path1/path2/filename',str(Uri(scheme='scheme',password='password',hostname='hostname',port=80,path='path1/path2',filename= 'filename')),'no username')
self.assertEqual('scheme:path1/path2/filename',str(Uri(scheme='scheme',username='username',password='password',path='path1/path2',filename= 'filename')),'no hostname')
self.assertEqual('//username:password@hostname:80/path1/path2/filename',str(Uri(username='username',password='password',hostname='hostname',port=80,path='path1/path2',filename= 'filename')),'no scheme')
self.assertEqual('path1/path2/filename',str(Uri(username='username',password='password',port=80,path='path1/path2',filename= 'filename')),'no scheme no hostname')
def testempty(self):
#tests for empty values
self.assertEqual('//username:password@hostname:80/path1/path2/filename',str(Uri(scheme=None,username='username',password='password',hostname='hostname',port=80,path='path1/path2',filename= 'filename')),'basis')
self.assertEqual('//username:password@hostname:80/path1/path2/filename',str(Uri(scheme='',username='username',password='password',hostname='hostname',port=80,path='path1/path2',filename= 'filename')),'basis')
self.assertEqual('scheme://hostname:80/path1/path2/filename',str(Uri(scheme='scheme',username=None,password=None,hostname='hostname',port=80,path='path1/path2',filename= 'filename')),'basis')
self.assertEqual('scheme://hostname:80/path1/path2/filename',str(Uri(scheme='scheme',username='',password='',hostname='hostname',port=80,path='path1/path2',filename= 'filename')),'basis')
#~ self.assertEqual('scheme://username:password@hostname:80/path1/path2/filename',str(Uri(scheme='scheme',username='username',password='password',hostname='hostname',port=80,path='path1/path2',filename= 'filename')),'basis')
def testcalls(self):
self.assertEqual('scheme:/path1/path2/filename2',Uri(scheme='scheme',path='/path1/path2',filename='filename').uri(filename='filename2'),'')
if __name__ == '__main__':
unittest.main()