summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorOlof Johansson <olof.johansson@axis.com>2013-01-29 08:50:08 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-17 22:32:05 +0000
commitf860059a4c928bdcccf286f1379ba2715e4f69e7 (patch)
treec7952cff7a80d54c3cdd65ef02721081bca99f13 /bitbake
parent7feca4e11e33661076385cdf18f00ea90b1604c1 (diff)
downloadpoky-f860059a4c928bdcccf286f1379ba2715e4f69e7.tar.gz
bitbake: fetch2: unittests for bb.fetch2.URI class
(Bitbake rev: a71e7d4137d2c5268b406f69992d09c00772a040) Signed-off-by: Olof Johansson <olof.johansson@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/tests/fetch.py226
1 files changed, 226 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 67eda5901a..e765ca7932 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -21,8 +21,234 @@ import unittest
21import tempfile 21import tempfile
22import subprocess 22import subprocess
23import os 23import os
24from bb.fetch2 import URI
24import bb 25import bb
25 26
27class URITest(unittest.TestCase):
28 test_uris = {
29 "http://www.google.com/index.html" : {
30 'uri': 'http://www.google.com/index.html',
31 'scheme': 'http',
32 'hostname': 'www.google.com',
33 'port': None,
34 'hostport': 'www.google.com',
35 'path': '/index.html',
36 'userinfo': '',
37 'username': '',
38 'password': '',
39 'params': {},
40 'relative': False
41 },
42 "http://www.google.com/index.html;param1=value1" : {
43 'uri': 'http://www.google.com/index.html;param1=value1',
44 'scheme': 'http',
45 'hostname': 'www.google.com',
46 'port': None,
47 'hostport': 'www.google.com',
48 'path': '/index.html',
49 'userinfo': '',
50 'username': '',
51 'password': '',
52 'params': {
53 'param1': 'value1'
54 },
55 'relative': False
56 },
57 "http://www.example.com:8080/index.html" : {
58 'uri': 'http://www.example.com:8080/index.html',
59 'scheme': 'http',
60 'hostname': 'www.example.com',
61 'port': 8080,
62 'hostport': 'www.example.com:8080',
63 'path': '/index.html',
64 'userinfo': '',
65 'username': '',
66 'password': '',
67 'params': {},
68 'relative': False
69 },
70 "cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg" : {
71 'uri': 'cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg',
72 'scheme': 'cvs',
73 'hostname': 'cvs.handhelds.org',
74 'port': None,
75 'hostport': 'cvs.handhelds.org',
76 'path': '/cvs',
77 'userinfo': 'anoncvs',
78 'username': 'anoncvs',
79 'password': '',
80 'params': {
81 'module': 'familiar/dist/ipkg'
82 },
83 'relative': False
84 },
85 "cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;tag=V0-99-81;module=familiar/dist/ipkg": {
86 'uri': 'cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;tag=V0-99-81;module=familiar/dist/ipkg',
87 'scheme': 'cvs',
88 'hostname': 'cvs.handhelds.org',
89 'port': None,
90 'hostport': 'cvs.handhelds.org',
91 'path': '/cvs',
92 'userinfo': 'anoncvs:anonymous',
93 'username': 'anoncvs',
94 'password': 'anonymous',
95 'params': {
96 'tag': 'V0-99-81',
97 'module': 'familiar/dist/ipkg'
98 },
99 'relative': False
100 },
101 "file://example.diff": { # NOTE: Not RFC compliant!
102 'uri': 'file:example.diff',
103 'scheme': 'file',
104 'hostname': '',
105 'port': None,
106 'hostport': '',
107 'path': 'example.diff',
108 'userinfo': '',
109 'username': '',
110 'password': '',
111 'params': {},
112 'relative': True
113 },
114 "file:example.diff": { # NOTE: RFC compliant version of the former
115 'uri': 'file:example.diff',
116 'scheme': 'file',
117 'hostname': '',
118 'port': None,
119 'hostport': '',
120 'path': 'example.diff',
121 'userinfo': '',
122 'userinfo': '',
123 'username': '',
124 'password': '',
125 'params': {},
126 'relative': True
127 },
128 "file:///tmp/example.diff": {
129 'uri': 'file:///tmp/example.diff',
130 'scheme': 'file',
131 'hostname': '',
132 'port': None,
133 'hostport': '',
134 'path': '/tmp/example.diff',
135 'userinfo': '',
136 'userinfo': '',
137 'username': '',
138 'password': '',
139 'params': {},
140 'relative': False
141 },
142 "git:///path/example.git": {
143 'uri': 'git:///path/example.git',
144 'scheme': 'git',
145 'hostname': '',
146 'port': None,
147 'hostport': '',
148 'path': '/path/example.git',
149 'userinfo': '',
150 'userinfo': '',
151 'username': '',
152 'password': '',
153 'params': {},
154 'relative': False
155 },
156 "git:path/example.git": {
157 'uri': 'git:path/example.git',
158 'scheme': 'git',
159 'hostname': '',
160 'port': None,
161 'hostport': '',
162 'path': 'path/example.git',
163 'userinfo': '',
164 'userinfo': '',
165 'username': '',
166 'password': '',
167 'params': {},
168 'relative': True
169 },
170 "git://example.net/path/example.git": {
171 'uri': 'git://example.net/path/example.git',
172 'scheme': 'git',
173 'hostname': 'example.net',
174 'port': None,
175 'hostport': 'example.net',
176 'path': '/path/example.git',
177 'userinfo': '',
178 'userinfo': '',
179 'username': '',
180 'password': '',
181 'params': {},
182 'relative': False
183 }
184 }
185
186 def test_uri(self):
187 for test_uri, ref in self.test_uris.items():
188 uri = URI(test_uri)
189
190 self.assertEqual(str(uri), ref['uri'])
191
192 # expected attributes
193 self.assertEqual(uri.scheme, ref['scheme'])
194
195 self.assertEqual(uri.userinfo, ref['userinfo'])
196 self.assertEqual(uri.username, ref['username'])
197 self.assertEqual(uri.password, ref['password'])
198
199 self.assertEqual(uri.hostname, ref['hostname'])
200 self.assertEqual(uri.port, ref['port'])
201 self.assertEqual(uri.hostport, ref['hostport'])
202
203 self.assertEqual(uri.path, ref['path'])
204 self.assertEqual(uri.params, ref['params'])
205
206 self.assertEqual(uri.relative, ref['relative'])
207
208 def test_dict(self):
209 for test in self.test_uris.values():
210 uri = URI()
211
212 self.assertEqual(uri.scheme, '')
213 self.assertEqual(uri.userinfo, '')
214 self.assertEqual(uri.username, '')
215 self.assertEqual(uri.password, '')
216 self.assertEqual(uri.hostname, '')
217 self.assertEqual(uri.port, None)
218 self.assertEqual(uri.path, '')
219 self.assertEqual(uri.params, {})
220
221
222 uri.scheme = test['scheme']
223 self.assertEqual(uri.scheme, test['scheme'])
224
225 uri.userinfo = test['userinfo']
226 self.assertEqual(uri.userinfo, test['userinfo'])
227 self.assertEqual(uri.username, test['username'])
228 self.assertEqual(uri.password, test['password'])
229
230 uri.hostname = test['hostname']
231 self.assertEqual(uri.hostname, test['hostname'])
232 self.assertEqual(uri.hostport, test['hostname'])
233
234 uri.port = test['port']
235 self.assertEqual(uri.port, test['port'])
236 self.assertEqual(uri.hostport, test['hostport'])
237
238 uri.path = test['path']
239 self.assertEqual(uri.path, test['path'])
240
241 uri.params = test['params']
242 self.assertEqual(uri.params, test['params'])
243
244 self.assertEqual(str(uri)+str(uri.relative), str(test['uri'])+str(test['relative']))
245
246 self.assertEqual(str(uri), test['uri'])
247
248 uri.params = {}
249 self.assertEqual(uri.params, {})
250 self.assertEqual(str(uri), (str(uri).split(";"))[0])
251
26 252
27class FetcherTest(unittest.TestCase): 253class FetcherTest(unittest.TestCase):
28 254