summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-02-18 21:21:50 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-19 15:38:48 +0000
commit94bca58067b8dcda3cb84a64d0fbce65c7bb8270 (patch)
tree16d93f45930db114ba9b253bb2c9cb8c8393d17d
parent8796ac8a55fa994e7c1969395597b9c1557005df (diff)
downloadpoky-94bca58067b8dcda3cb84a64d0fbce65c7bb8270.tar.gz
bitbake: toaster: toastergui unit tests convert to use fixtures
Instead of having to manually write up in the setUp function all the different objects to create in the database, just specifiy them in a fixture and load it. This has the advantage that it can be used on a live server by using the ./manage.py loaddata command and can then be inspected. (Bitbake rev: 8a653ad8b075892d24d15696b3070c5a28a4fbe2) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml446
-rw-r--r--bitbake/lib/toaster/toastergui/tests.py255
2 files changed, 488 insertions, 213 deletions
diff --git a/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml b/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
new file mode 100644
index 0000000000..2d83ff895d
--- /dev/null
+++ b/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml
@@ -0,0 +1,446 @@
1<?xml version="1.0" encoding="utf-8"?>
2<django-objects version="1.0">
3 <object pk="1" model="orm.project">
4 <field type="CharField" name="name">a test project</field>
5 <field type="CharField" name="short_description"></field>
6 <field to="orm.bitbakeversion" name="bitbake_version" rel="ManyToOneRel">1</field>
7 <field to="orm.release" name="release" rel="ManyToOneRel">1</field>
8 <field type="DateTimeField" name="created">2016-02-15T18:46:20.098248+00:00</field>
9 <field type="DateTimeField" name="updated">2016-02-15T18:46:20.098392+00:00</field>
10 <field type="IntegerField" name="user_id"><None></None></field>
11 <field type="BooleanField" name="is_default">False</field>
12 </object>
13 <object pk="2" model="orm.project">
14 <field type="CharField" name="name">z test project</field>
15 <field type="CharField" name="short_description"></field>
16 <field to="orm.bitbakeversion" name="bitbake_version" rel="ManyToOneRel">1</field>
17 <field to="orm.release" name="release" rel="ManyToOneRel">2</field>
18 <field type="DateTimeField" name="created">2016-02-15T18:46:20.107936+00:00</field>
19 <field type="DateTimeField" name="updated">2016-02-15T18:46:20.108066+00:00</field>
20 <field type="IntegerField" name="user_id"><None></None></field>
21 <field type="BooleanField" name="is_default">False</field>
22 </object>
23 <object pk="1" model="orm.ProjectVariable">
24 <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
25 <field type="CharField" name="name">machine</field>
26 <field type="TextField" name="value">qemux86</field>
27 </object>
28 <object pk="2" model="orm.ProjectVariable">
29 <field to="orm.project" name="project" rel="ManyToOneRel">2</field>
30 <field type="CharField" name="name">machine</field>
31 <field type="TextField" name="value">qemux86</field>
32 </object>
33 <object pk="1" model="orm.build">
34 <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
35 <field type="CharField" name="machine">x12</field>
36 <field type="CharField" name="distro"></field>
37 <field type="CharField" name="distro_version"></field>
38 <field type="DateTimeField" name="started_on">2016-02-14T18:46:20.114530+00:00</field>
39 <field type="DateTimeField" name="completed_on">2016-02-14T18:46:20.114530+00:00</field>
40 <field type="IntegerField" name="outcome">0</field>
41 <field type="CharField" name="cooker_log_path"></field>
42 <field type="CharField" name="build_name">a</field>
43 <field type="CharField" name="bitbake_version"></field>
44 </object>
45 <object pk="2" model="orm.build">
46 <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
47 <field type="CharField" name="machine">raspberrypi2</field>
48 <field type="CharField" name="distro"></field>
49 <field type="CharField" name="distro_version"></field>
50 <field type="DateTimeField" name="started_on">2016-02-13T18:46:20.114530+00:00</field>
51 <field type="DateTimeField" name="completed_on">2016-02-13T18:46:20.114530+00:00</field>
52 <field type="IntegerField" name="outcome">0</field>
53 <field type="CharField" name="cooker_log_path"></field>
54 <field type="CharField" name="build_name">b</field>
55 <field type="CharField" name="bitbake_version"></field>
56 </object>
57 <object pk="3" model="orm.build">
58 <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
59 <field type="CharField" name="machine">qemux86</field>
60 <field type="CharField" name="distro"></field>
61 <field type="CharField" name="distro_version"></field>
62 <field type="DateTimeField" name="started_on">2016-02-12T18:46:20.114530+00:00</field>
63 <field type="DateTimeField" name="completed_on">2016-02-12T18:46:20.114530+00:00</field>
64 <field type="IntegerField" name="outcome">1</field>
65 <field type="CharField" name="cooker_log_path"></field>
66 <field type="CharField" name="build_name">c</field>
67 <field type="CharField" name="bitbake_version"></field>
68 </object>
69 <object pk="4" model="orm.build">
70 <field to="orm.project" name="project" rel="ManyToOneRel">2</field>
71 <field type="CharField" name="machine">qemux86</field>
72 <field type="CharField" name="distro"></field>
73 <field type="CharField" name="distro_version"></field>
74 <field type="DateTimeField" name="started_on">2016-02-11T18:46:20.114530+00:00</field>
75 <field type="DateTimeField" name="completed_on">2016-02-11T18:46:20.114530+00:00</field>
76 <field type="IntegerField" name="outcome">0</field>
77 <field type="CharField" name="cooker_log_path"></field>
78 <field type="CharField" name="build_name">d</field>
79 <field type="CharField" name="bitbake_version"></field>
80 </object>
81 <object pk="1" model="orm.target">
82 <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
83 <field type="CharField" name="target">a image recipe</field>
84 <field type="CharField" name="task"><None></None></field>
85 <field type="BooleanField" name="is_image">False</field>
86 <field type="IntegerField" name="image_size">0</field>
87 <field type="CharField" name="license_manifest_path"><None></None></field>
88 </object>
89 <object pk="2" model="orm.target">
90 <field to="orm.build" name="build" rel="ManyToOneRel">2</field>
91 <field type="CharField" name="target">z something</field>
92 <field type="CharField" name="task"><None></None></field>
93 <field type="BooleanField" name="is_image">False</field>
94 <field type="IntegerField" name="image_size">0</field>
95 <field type="CharField" name="license_manifest_path"><None></None></field>
96 </object>
97 <object pk="3" model="orm.target">
98 <field to="orm.build" name="build" rel="ManyToOneRel">3</field>
99 <field type="CharField" name="target">h recipe</field>
100 <field type="CharField" name="task"><None></None></field>
101 <field type="BooleanField" name="is_image">False</field>
102 <field type="IntegerField" name="image_size">0</field>
103 <field type="CharField" name="license_manifest_path"><None></None></field>
104 </object>
105 <object pk="1" model="orm.package">
106 <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
107 <field to="orm.recipe" name="recipe" rel="ManyToOneRel">2</field>
108 <field type="CharField" name="name">b pkg</field>
109 <field type="CharField" name="installed_name"></field>
110 <field type="CharField" name="version"></field>
111 <field type="CharField" name="revision"></field>
112 <field type="TextField" name="summary"></field>
113 <field type="TextField" name="description"></field>
114 <field type="IntegerField" name="size">777</field>
115 <field type="IntegerField" name="installed_size">0</field>
116 <field type="CharField" name="section"></field>
117 <field type="CharField" name="license">a license</field>
118 </object>
119 <object pk="2" model="orm.package">
120 <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
121 <field to="orm.recipe" name="recipe" rel="ManyToOneRel">2</field>
122 <field type="CharField" name="name">f pkg</field>
123 <field type="CharField" name="installed_name"></field>
124 <field type="CharField" name="version"></field>
125 <field type="CharField" name="revision"></field>
126 <field type="TextField" name="summary"></field>
127 <field type="TextField" name="description"></field>
128 <field type="IntegerField" name="size">4</field>
129 <field type="IntegerField" name="installed_size">10</field>
130 <field type="CharField" name="section"></field>
131 <field type="CharField" name="license">z license</field>
132 </object>
133 <object pk="3" model="orm.package">
134 <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field>
135 <field to="orm.recipe" name="recipe" rel="ManyToOneRel">1</field>
136 <field type="CharField" name="name">a custom image pkg</field>
137 <field type="CharField" name="installed_name"></field>
138 <field type="CharField" name="version"></field>
139 <field type="CharField" name="revision"></field>
140 <field type="TextField" name="summary"></field>
141 <field type="TextField" name="description"></field>
142 <field type="IntegerField" name="size">10</field>
143 <field type="IntegerField" name="installed_size">0</field>
144 <field type="CharField" name="section"></field>
145 <field type="CharField" name="license">h license</field>
146 </object>
147 <object pk="4" model="orm.package">
148 <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field>
149 <field to="orm.recipe" name="recipe" rel="ManyToOneRel">2</field>
150 <field type="CharField" name="name">z custom image pkg</field>
151 <field type="CharField" name="installed_name"></field>
152 <field type="CharField" name="version"></field>
153 <field type="CharField" name="revision"></field>
154 <field type="TextField" name="summary"></field>
155 <field type="TextField" name="description"></field>
156 <field type="IntegerField" name="size">5</field>
157 <field type="IntegerField" name="installed_size">0</field>
158 <field type="CharField" name="section"></field>
159 <field type="CharField" name="license">z license</field>
160 </object>
161 <object pk="5" model="orm.package">
162 <field to="orm.build" name="build" rel="ManyToOneRel">1</field>
163 <field to="orm.recipe" name="recipe" rel="ManyToOneRel">4</field>
164 <field type="CharField" name="name">a custom image pkg</field>
165 <field type="CharField" name="installed_name"></field>
166 <field type="CharField" name="version"></field>
167 <field type="CharField" name="revision"></field>
168 <field type="TextField" name="summary"></field>
169 <field type="TextField" name="description"></field>
170 <field type="IntegerField" name="size">2</field>
171 <field type="IntegerField" name="installed_size">0</field>
172 <field type="CharField" name="section"></field>
173 <field type="CharField" name="license">h licence</field>
174 </object>
175 <object pk="1" model="orm.target_installed_package">
176 <field to="orm.target" name="target" rel="ManyToOneRel">1</field>
177 <field to="orm.package" name="package" rel="ManyToOneRel">1</field>
178 </object>
179 <object pk="2" model="orm.target_installed_package">
180 <field to="orm.target" name="target" rel="ManyToOneRel">1</field>
181 <field to="orm.package" name="package" rel="ManyToOneRel">2</field>
182 </object>
183 <object pk="3" model="orm.target_installed_package">
184 <field to="orm.target" name="target" rel="ManyToOneRel">1</field>
185 <field to="orm.package" name="package" rel="ManyToOneRel">3</field>
186 </object>
187 <!-- Note that these augment the existing orm.package of the same pk -->
188 <object pk="4" model="orm.customimagepackage">
189 <field to="orm.customimagerecipe" name="recipe_includes" rel="ManyToManyRel"></field>
190 <field to="orm.customimagerecipe" name="recipe_excludes" rel="ManyToManyRel"></field>
191 <field to="orm.customimagerecipe" name="recipe_appends" rel="ManyToManyRel"><object pk="3"></object></field>
192 </object>
193 <object pk="5" model="orm.customimagepackage">
194 <field to="orm.customimagerecipe" name="recipe_includes" rel="ManyToManyRel"></field>
195 <field to="orm.customimagerecipe" name="recipe_excludes" rel="ManyToManyRel"></field>
196 <field to="orm.customimagerecipe" name="recipe_appends" rel="ManyToManyRel"><object pk="3"></object></field>
197 </object>
198 <object pk="1" model="orm.recipe">
199 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
200 <field type="IntegerField" name="up_id"><None></None></field>
201 <field type="DateTimeField" name="up_date"><None></None></field>
202 <field type="CharField" name="name">z recipe</field>
203 <field type="CharField" name="version">5.2</field>
204 <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
205 <field type="TextField" name="summary">z recipe</field>
206 <field type="TextField" name="description">z recipe</field>
207 <field type="CharField" name="section">z section</field>
208 <field type="CharField" name="license">z license</field>
209 <field type="CharField" name="homepage"></field>
210 <field type="CharField" name="bugtracker"></field>
211 <field type="FilePathField" name="file_path"></field>
212 <field type="CharField" name="pathflags"></field>
213 <field type="BooleanField" name="is_image">False</field>
214 </object>
215 <object pk="2" model="orm.recipe">
216 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
217 <field type="IntegerField" name="up_id"><None></None></field>
218 <field type="DateTimeField" name="up_date"><None></None></field>
219 <field type="CharField" name="name">a recipe</field>
220 <field type="CharField" name="version">1.2</field>
221 <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">1</field>
222 <field type="TextField" name="summary">a recipe</field>
223 <field type="TextField" name="description">a recipe</field>
224 <field type="CharField" name="section">a section</field>
225 <field type="CharField" name="license">a license</field>
226 <field type="CharField" name="homepage"></field>
227 <field type="CharField" name="bugtracker"></field>
228 <field type="FilePathField" name="file_path">a_recipe.bb</field>
229 <field type="CharField" name="pathflags"></field>
230 <field type="BooleanField" name="is_image">False</field>
231 </object>
232 <object pk="3" model="orm.recipe">
233 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
234 <field type="IntegerField" name="up_id"><None></None></field>
235 <field type="DateTimeField" name="up_date"><None></None></field>
236 <field type="CharField" name="name">a custom recipe</field>
237 <field type="CharField" name="version"></field>
238 <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
239 <field type="TextField" name="summary"></field>
240 <field type="TextField" name="description"></field>
241 <field type="CharField" name="section"></field>
242 <field type="CharField" name="license"></field>
243 <field type="CharField" name="homepage"></field>
244 <field type="CharField" name="bugtracker"></field>
245 <field type="FilePathField" name="file_path">custr</field>
246 <field type="CharField" name="pathflags"></field>
247 <field type="BooleanField" name="is_image">False</field>
248 </object>
249 <object pk="4" model="orm.recipe">
250 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
251 <field type="IntegerField" name="up_id"><None></None></field>
252 <field type="DateTimeField" name="up_date"><None></None></field>
253 <field type="CharField" name="name">a image recipe</field>
254 <field type="CharField" name="version">1.2</field>
255 <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">1</field>
256 <field type="TextField" name="summary">one recipe</field>
257 <field type="TextField" name="description">recipe</field>
258 <field type="CharField" name="section">A</field>
259 <field type="CharField" name="license">A</field>
260 <field type="CharField" name="homepage"></field>
261 <field type="CharField" name="bugtracker"></field>
262 <field type="FilePathField" name="file_path">/one/</field>
263 <field type="CharField" name="pathflags"></field>
264 <field type="BooleanField" name="is_image">True</field>
265 </object>
266 <object pk="5" model="orm.recipe">
267 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
268 <field type="IntegerField" name="up_id"><None></None></field>
269 <field type="DateTimeField" name="up_date"><None></None></field>
270 <field type="CharField" name="name">z image recipe</field>
271 <field type="CharField" name="version">1.3</field>
272 <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
273 <field type="TextField" name="summary">two image recipe</field>
274 <field type="TextField" name="description">recipe two</field>
275 <field type="CharField" name="section">B</field>
276 <field type="CharField" name="license">Z</field>
277 <field type="CharField" name="homepage"></field>
278 <field type="CharField" name="bugtracker"></field>
279 <field type="FilePathField" name="file_path">/two/</field>
280 <field type="CharField" name="pathflags"></field>
281 <field type="BooleanField" name="is_image">True</field>
282 </object>
283 <object pk="6" model="orm.recipe">
284 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
285 <field type="IntegerField" name="up_id"><None></None></field>
286 <field type="DateTimeField" name="up_date"><None></None></field>
287 <field type="CharField" name="name">z custom recipe</field>
288 <field type="CharField" name="version"></field>
289 <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
290 <field type="TextField" name="summary"></field>
291 <field type="TextField" name="description"></field>
292 <field type="CharField" name="section"></field>
293 <field type="CharField" name="license"></field>
294 <field type="CharField" name="homepage"></field>
295 <field type="CharField" name="bugtracker"></field>
296 <field type="FilePathField" name="file_path">zzzz</field>
297 <field type="CharField" name="pathflags"></field>
298 <field type="BooleanField" name="is_image">False</field>
299 </object>
300 <object pk="1" model="orm.machine">
301 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
302 <field type="IntegerField" name="up_id"><None></None></field>
303 <field type="DateTimeField" name="up_date"><None></None></field>
304 <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">1</field>
305 <field type="CharField" name="name">a machine</field>
306 <field type="CharField" name="description">a machine</field>
307 </object>
308 <object pk="2" model="orm.machine">
309 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
310 <field type="IntegerField" name="up_id"><None></None></field>
311 <field type="DateTimeField" name="up_date"><None></None></field>
312 <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">2</field>
313 <field type="CharField" name="name">z machine</field>
314 <field type="CharField" name="description">z machine</field>
315 </object>
316 <object pk="3" model="orm.machine">
317 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
318 <field type="IntegerField" name="up_id"><None></None></field>
319 <field type="DateTimeField" name="up_date"><None></None></field>
320 <field to="orm.layer_version" name="layer_version" rel="ManyToOneRel">1</field>
321 <field type="CharField" name="name">g machine</field>
322 <field type="CharField" name="description">g machine</field>
323 </object>
324 <object pk="1" model="orm.layersource">
325 <field type="CharField" name="name">local</field>
326 <field type="IntegerField" name="sourcetype">1</field>
327 <field type="CharField" name="apiurl"></field>
328 </object>
329 <object pk="1" model="orm.bitbakeversion">
330 <field type="CharField" name="name">test bbv</field>
331 <field type="CharField" name="giturl">/tmp/</field>
332 <field type="CharField" name="branch">master</field>
333 <field type="CharField" name="dirpath"></field>
334 </object>
335 <object pk="1" model="orm.release">
336 <field type="CharField" name="name">test release</field>
337 <field type="CharField" name="description"></field>
338 <field to="orm.bitbakeversion" name="bitbake_version" rel="ManyToOneRel">1</field>
339 <field type="CharField" name="branch_name">master</field>
340 <field type="TextField" name="helptext"><None></None></field>
341 </object>
342 <object pk="2" model="orm.release">
343 <field type="CharField" name="name">test release 2</field>
344 <field type="CharField" name="description"></field>
345 <field to="orm.bitbakeversion" name="bitbake_version" rel="ManyToOneRel">1</field>
346 <field type="CharField" name="branch_name">master</field>
347 <field type="TextField" name="helptext"><None></None></field>
348 </object>
349 <object pk="1" model="orm.releaselayersourcepriority">
350 <field to="orm.release" name="release" rel="ManyToOneRel">1</field>
351 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
352 <field type="IntegerField" name="priority">0</field>
353 </object>
354 <object pk="1" model="orm.branch">
355 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
356 <field type="IntegerField" name="up_id"><None></None></field>
357 <field type="DateTimeField" name="up_date"><None></None></field>
358 <field type="CharField" name="name">master</field>
359 <field type="CharField" name="short_description"></field>
360 </object>
361 <object pk="1" model="orm.layer">
362 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel"><None></None></field>
363 <field type="IntegerField" name="up_id"><None></None></field>
364 <field type="DateTimeField" name="up_date"><None></None></field>
365 <field type="CharField" name="name">a layer</field>
366 <field type="CharField" name="layer_index_url"></field>
367 <field type="CharField" name="vcs_url">/tmp/</field>
368 <field type="CharField" name="vcs_web_url"><None></None></field>
369 <field type="CharField" name="vcs_web_tree_base_url"><None></None></field>
370 <field type="CharField" name="vcs_web_file_base_url"><None></None></field>
371 <field type="TextField" name="summary"><None></None></field>
372 <field type="TextField" name="description"><None></None></field>
373 </object>
374 <object pk="2" model="orm.layer">
375 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
376 <field type="IntegerField" name="up_id"><None></None></field>
377 <field type="DateTimeField" name="up_date"><None></None></field>
378 <field type="CharField" name="name">z layer</field>
379 <field type="CharField" name="layer_index_url"></field>
380 <field type="CharField" name="vcs_url">git://two/</field>
381 <field type="CharField" name="vcs_web_url"><None></None></field>
382 <field type="CharField" name="vcs_web_tree_base_url"><None></None></field>
383 <field type="CharField" name="vcs_web_file_base_url"><None></None></field>
384 <field type="TextField" name="summary"><None></None></field>
385 <field type="TextField" name="description"><None></None></field>
386 </object>
387 <object pk="1" model="orm.layer_version">
388 <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field>
389 <field to="orm.layer" name="layer" rel="ManyToOneRel">1</field>
390 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
391 <field type="IntegerField" name="up_id"><None></None></field>
392 <field type="DateTimeField" name="up_date"><None></None></field>
393 <field to="orm.branch" name="up_branch" rel="ManyToOneRel">1</field>
394 <field type="CharField" name="branch"></field>
395 <field type="CharField" name="commit">master</field>
396 <field type="CharField" name="dirpath">/tmp/</field>
397 <field type="IntegerField" name="priority">0</field>
398 <field type="FilePathField" name="local_path">/</field>
399 <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
400 </object>
401 <object pk="2" model="orm.layer_version">
402 <field to="orm.build" name="build" rel="ManyToOneRel"><None></None></field>
403 <field to="orm.layer" name="layer" rel="ManyToOneRel">2</field>
404 <field to="orm.layersource" name="layer_source" rel="ManyToOneRel">1</field>
405 <field type="IntegerField" name="up_id"><None></None></field>
406 <field type="DateTimeField" name="up_date"><None></None></field>
407 <field to="orm.branch" name="up_branch" rel="ManyToOneRel">1</field>
408 <field type="CharField" name="branch"></field>
409 <field type="CharField" name="commit">master</field>
410 <field type="CharField" name="dirpath"><None></None></field>
411 <field type="IntegerField" name="priority">0</field>
412 <field type="FilePathField" name="local_path">/</field>
413 <field to="orm.project" name="project" rel="ManyToOneRel"><None></None></field>
414 </object>
415 <object pk="1" model="orm.projectlayer">
416 <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
417 <field to="orm.layer_version" name="layercommit" rel="ManyToOneRel">1</field>
418 <field type="BooleanField" name="optional">True</field>
419 </object>
420 <object pk="3" model="orm.customimagerecipe">
421 <field to="orm.recipe" name="base_recipe" rel="ManyToOneRel">2</field>
422 <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
423 <field type="DateTimeField" name="last_updated"><None></None></field>
424 </object>
425 <object pk="6" model="orm.customimagerecipe">
426 <field to="orm.recipe" name="base_recipe" rel="ManyToOneRel">4</field>
427 <field to="orm.project" name="project" rel="ManyToOneRel">1</field>
428 <field type="DateTimeField" name="last_updated"><None></None></field>
429 </object>
430 <object pk="1" model="orm.logmessage">
431 <field to="orm.build" name="build" rel="ManyToOneRel">2</field>
432 <field to="orm.task" name="task" rel="ManyToOneRel"><None></None></field>
433 <field type="IntegerField" name="level">1</field>
434 <field type="TextField" name="message"><None></None></field>
435 <field type="FilePathField" name="pathname"></field>
436 <field type="IntegerField" name="lineno"><None></None></field>
437 </object>
438 <object pk="2" model="orm.logmessage">
439 <field to="orm.build" name="build" rel="ManyToOneRel">2</field>
440 <field to="orm.task" name="task" rel="ManyToOneRel"><None></None></field>
441 <field type="IntegerField" name="level">2</field>
442 <field type="TextField" name="message"><None></None></field>
443 <field type="FilePathField" name="pathname"></field>
444 <field type="IntegerField" name="lineno"><None></None></field>
445 </object>
446</django-objects>
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index 56a7d7e860..1b6e78d517 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -51,205 +51,17 @@ CLI_BUILDS_PROJECT_NAME = 'Command line builds'
51class ViewTests(TestCase): 51class ViewTests(TestCase):
52 """Tests to verify view APIs.""" 52 """Tests to verify view APIs."""
53 53
54 def setUp(self): 54 fixtures = ['toastergui-unittest-data']
55 bbv = BitbakeVersion.objects.create(name="test bbv", giturl="/tmp/",
56 branch="master", dirpath="")
57 release = Release.objects.create(name="test release",
58 branch_name="master",
59 bitbake_version=bbv)
60 release2 = Release.objects.create(name="test release 2",
61 branch_name="master",
62 bitbake_version=bbv)
63
64 self.project = Project.objects.create_project(name=PROJECT_NAME,
65 release=release)
66
67 self.project2 = Project.objects.create_project(name=PROJECT_NAME2,
68 release=release2)
69
70 now = timezone.now()
71 later = now + timedelta(days=1)
72
73 build = Build.objects.create(project=self.project,
74 started_on=now,
75 completed_on=now,
76 outcome=Build.SUCCEEDED)
77
78 # for testing BuildsTable
79 build1 = Build.objects.create(project=self.project,
80 started_on=now,
81 completed_on=now,
82 outcome=Build.SUCCEEDED,
83 machine="raspberrypi2")
84
85 Build.objects.create(project=self.project,
86 started_on=later,
87 completed_on=later,
88 outcome=Build.FAILED,
89 machine="qemux86")
90
91 Build.objects.create(project=self.project2,
92 started_on=later,
93 completed_on=later,
94 outcome=Build.SUCCEEDED,
95 machine="qemux86")
96
97 # to test sorting by errors and warnings in BuildsTable
98 LogMessage.objects.create(build=build1, level=LogMessage.WARNING)
99 LogMessage.objects.create(build=build1, level=LogMessage.ERROR)
100
101 layersrc = LayerSource.objects.create(sourcetype=LayerSource.TYPE_IMPORTED)
102 self.priority = ReleaseLayerSourcePriority.objects.create(release=release,
103 layer_source=layersrc)
104 layer = Layer.objects.create(name="base-layer", layer_source=layersrc,
105 vcs_url="/tmp/")
106
107 layer_two = Layer.objects.create(name="z-layer",
108 layer_source=layersrc,
109 vcs_url="git://two/")
110
111
112 branch = Branch.objects.create(name="master", layer_source=layersrc)
113
114 self.lver = Layer_Version.objects.create(layer=layer,
115 project=self.project,
116 layer_source=layersrc,
117 commit="master",
118 dirpath="/tmp/",
119 up_branch=branch)
120
121 lver_two = Layer_Version.objects.create(layer=layer_two,
122 layer_source=layersrc,
123 commit="master",
124 up_branch=branch)
125
126 Recipe.objects.create(layer_source=layersrc,
127 name="z recipe",
128 version="5.2",
129 summary="z recipe",
130 description="G recipe",
131 license="Z GPL",
132 section="h section",
133 layer_version=lver_two)
134
135 # Create a dummy recipe file for the custom image generation to read
136 open("/tmp/my_recipe.bb", 'wa').close()
137 self.recipe1 = Recipe.objects.create(layer_source=layersrc,
138 name="base-recipe",
139 version="1.2",
140 summary="one recipe",
141 description="recipe",
142 section="A section",
143 license="Apache",
144 layer_version=self.lver,
145 file_path="my_recipe.bb")
146
147 Machine.objects.create(layer_version=self.lver, name="wisk",
148 description="wisking machine")
149 Machine.objects.create(layer_version=self.lver, name="zap",
150 description="zap machine")
151 Machine.objects.create(layer_version=lver_two, name="xray",
152 description="xray machine")
153
154
155
156 ProjectLayer.objects.create(project=self.project, layercommit=self.lver)
157
158 lver_custom = Layer_Version.objects.create(layer=layer,
159 project=self.project,
160 layer_source=layersrc,
161 commit="mymaster",
162 up_branch=branch)
163
164 self.customr = CustomImageRecipe.objects.create(\
165 name="custom recipe", project=self.project,
166 base_recipe=self.recipe1,
167 file_path="custr",
168 layer_version=lver_custom)
169
170 self.package = Package.objects.create(name='pkg1',
171 size=999,
172 recipe=self.recipe1,
173 license="HHH",
174 build=build)
175
176 Package.objects.create(name='A pkg1',
177 size=777,
178 recipe=self.recipe1,
179 build=build)
180
181 Package.objects.create(name='zpkg1',
182 recipe=self.recipe1,
183 build=build,
184 size=4,
185 license="ZZ")
186
187 self.cust_package = CustomImagePackage.objects.create(
188 name="A pkg",
189 recipe=self.recipe1,
190 size=10,
191 license="AAA")
192
193 self.customr.appends_set.add(self.cust_package)
194
195 # recipe with project for testing AvailableRecipe table
196 self.recipe2 = Recipe.objects.create(layer_source=layersrc,
197 name="fancy-recipe",
198 version="1.4",
199 summary="a fancy recipe",
200 description="fancy recipe",
201 license="MIT",
202 layer_version=self.lver,
203 section="Z section",
204 file_path='/home/foo')
205
206 # additional package for the sorting for the SelectPackagesTable
207 cust_package_two = CustomImagePackage.objects.create(name="ZZ pkg",
208 size=5,
209 recipe=self.recipe2)
210
211 self.customr.appends_set.add(cust_package_two)
212
213 Package.objects.create(name='one1',
214 recipe=self.recipe2,
215 build=build,
216 size=2,
217 license="L")
218
219 Recipe.objects.create(layer_source=layersrc,
220 is_image=True,
221 name="Test image one",
222 version="1.2",
223 summary="one recipe",
224 description="recipe",
225 section="A",
226 license="A",
227 file_path="/one/",
228 layer_version=self.lver)
229
230 zrecipe = Recipe.objects.create(layer_source=layersrc,
231 is_image=True,
232 name="Z Test image two",
233 version="1.3",
234 summary="two image recipe",
235 description="recipe two",
236 section="B",
237 license="Z",
238 file_path="/two/",
239 layer_version=lver_two)
240
241 CustomImageRecipe.objects.create(name="z custom recipe",
242 project=self.project,
243 base_recipe=zrecipe,
244 file_path="zzzz",
245 layer_version=lver_custom)
246
247 # Packages in PackagesTable requre that the recipe has been built so
248 # we need to create a target and build pair
249 target = Target.objects.create(target=self.recipe1.name,
250 build=build)
251 55
56 def setUp(self):
252 57
58 self.project = Project.objects.first()
59 self.recipe1 = Recipe.objects.get(pk=2)
60 self.recipe2 = Recipe.objects.last()
61 self.customr = CustomImageRecipe.objects.first()
62 self.cust_package = CustomImagePackage.objects.first()
63 self.package = Package.objects.first()
64 self.lver = Layer_Version.objects.first()
253 65
254 def test_get_base_call_returns_html(self): 66 def test_get_base_call_returns_html(self):
255 """Basic test for all-projects view""" 67 """Basic test for all-projects view"""
@@ -271,7 +83,7 @@ class ViewTests(TestCase):
271 self.assertEqual(data["error"], "ok") 83 self.assertEqual(data["error"], "ok")
272 self.assertTrue("rows" in data) 84 self.assertTrue("rows" in data)
273 85
274 self.assertTrue(PROJECT_NAME in [x["name"] for x in data["rows"]]) 86 self.assertTrue(self.project.name in [x["name"] for x in data["rows"]])
275 self.assertTrue("id" in data["rows"][0]) 87 self.assertTrue("id" in data["rows"][0])
276 88
277 def test_typeaheads(self): 89 def test_typeaheads(self):
@@ -333,11 +145,13 @@ class ViewTests(TestCase):
333 145
334 def test_xhr_import_layer(self): 146 def test_xhr_import_layer(self):
335 """Test xhr_importlayer API""" 147 """Test xhr_importlayer API"""
148 LayerSource.objects.create(sourcetype=LayerSource.TYPE_IMPORTED)
336 #Test for importing an already existing layer 149 #Test for importing an already existing layer
337 args = {'vcs_url' : "git://git.example.com/test", 150 args = {'vcs_url' : "git://git.example.com/test",
338 'name' : "base-layer", 151 'name' : "base-layer",
339 'git_ref': "c12b9596afd236116b25ce26dbe0d793de9dc7ce", 152 'git_ref': "c12b9596afd236116b25ce26dbe0d793de9dc7ce",
340 'project_id': 1, 'dir_path' : "/path/in/repository"} 153 'project_id': self.project.id,
154 'dir_path' : "/path/in/repository"}
341 response = self.client.post(reverse('xhr_importlayer'), args) 155 response = self.client.post(reverse('xhr_importlayer'), args)
342 data = json.loads(response.content) 156 data = json.loads(response.content)
343 self.assertEqual(response.status_code, 200) 157 self.assertEqual(response.status_code, 200)
@@ -407,13 +221,12 @@ class ViewTests(TestCase):
407 221
408 def test_xhr_custom_details(self): 222 def test_xhr_custom_details(self):
409 """Test getting custom recipe details""" 223 """Test getting custom recipe details"""
410 name = "custom recipe"
411 url = reverse('xhr_customrecipe_id', args=(self.customr.id,)) 224 url = reverse('xhr_customrecipe_id', args=(self.customr.id,))
412 response = self.client.get(url) 225 response = self.client.get(url)
413 self.assertEqual(response.status_code, 200) 226 self.assertEqual(response.status_code, 200)
414 expected = {"error": "ok", 227 expected = {"error": "ok",
415 "info": {'id': self.customr.id, 228 "info": {'id': self.customr.id,
416 'name': name, 229 'name': self.customr.name,
417 'base_recipe_id': self.recipe1.id, 230 'base_recipe_id': self.recipe1.id,
418 'project_id': self.project.id, 231 'project_id': self.project.id,
419 } 232 }
@@ -484,6 +297,10 @@ class ViewTests(TestCase):
484 {"error": "ok"}) 297 {"error": "ok"})
485 298
486 def test_download_custom_recipe(self): 299 def test_download_custom_recipe(self):
300 """Download the recipe file generated for the custom image"""
301
302 # Create a dummy recipe file for the custom image generation to read
303 open("/tmp/a_recipe.bb", 'wa').close()
487 response = self.client.get(reverse('customrecipedownload', 304 response = self.client.get(reverse('customrecipedownload',
488 args=(self.project.id, 305 args=(self.project.id,
489 self.customr.id))) 306 self.customr.id)))
@@ -503,8 +320,6 @@ class ViewTests(TestCase):
503 row2 = next(x for x in rows if x['name'] == self.recipe2.name) 320 row2 = next(x for x in rows if x['name'] == self.recipe2.name)
504 321
505 self.assertEqual(response.status_code, 200, 'should be 200 OK status') 322 self.assertEqual(response.status_code, 200, 'should be 200 OK status')
506 # All recipes in the setUp
507 self.assertEqual(len(rows), 5, 'should be 5 recipes')
508 323
509 # check other columns have been populated correctly 324 # check other columns have been populated correctly
510 self.assertEqual(row1['name'], self.recipe1.name) 325 self.assertEqual(row1['name'], self.recipe1.name)
@@ -529,13 +344,20 @@ class ViewTests(TestCase):
529 options['format'] = "json" 344 options['format'] = "json"
530 options['nocache'] = "true" 345 options['nocache'] = "true"
531 request = RequestFactory().get('/', options) 346 request = RequestFactory().get('/', options)
347
348 # This is the image recipe needed for a package list for
349 # PackagesTable do this here to throw a non exist exception
350 image_recipe = Recipe.objects.get(pk=4)
351
532 # Add any kwargs that are needed by any of the possible tables 352 # Add any kwargs that are needed by any of the possible tables
533 response = table.get(request, 353 args = {'pid': self.project.id,
534 pid=self.project.id, 354 'layerid': self.lver.pk,
535 layerid=self.lver.pk, 355 'recipeid': self.recipe1.pk,
536 recipeid=self.recipe1.pk, 356 'recipe_id': image_recipe.pk,
537 recipe_id=self.recipe1.pk, 357 'custrecipeid': self.customr.pk
538 custrecipeid=self.customr.pk) 358 }
359
360 response = table.get(request, **args)
539 return json.loads(response.content) 361 return json.loads(response.content)
540 362
541 # Get a list of classes in tables module 363 # Get a list of classes in tables module
@@ -562,10 +384,14 @@ class ViewTests(TestCase):
562 384
563 if '-' in table.default_orderby: 385 if '-' in table.default_orderby:
564 self.assertTrue(row_one >= row_two, 386 self.assertTrue(row_one >= row_two,
565 "Default ordering not working on %s" % name) 387 "Default ordering not working on %s"
388 " '%s' should be >= '%s'" %
389 (name, row_one, row_two))
566 else: 390 else:
567 self.assertTrue(row_one <= row_two, 391 self.assertTrue(row_one <= row_two,
568 "Default ordering not working on %s" % name) 392 "Default ordering not working on %s"
393 " '%s' should be <= '%s'" %
394 (name, row_one, row_two))
569 395
570 # Test the column ordering and filtering functionality 396 # Test the column ordering and filtering functionality
571 for column in table.columns: 397 for column in table.columns:
@@ -580,7 +406,9 @@ class ViewTests(TestCase):
580 406
581 self.assertTrue(row_one <= row_two, 407 self.assertTrue(row_one <= row_two,
582 "Ascending sort applied but row 0 is less " 408 "Ascending sort applied but row 0 is less "
583 "than row 1") 409 "than row 1 %s %s " %
410 (column['field_name'], name))
411
584 412
585 descending = get_data(table_cls(), 413 descending = get_data(table_cls(),
586 {"orderby" : 414 {"orderby" :
@@ -591,7 +419,8 @@ class ViewTests(TestCase):
591 419
592 self.assertTrue(row_one >= row_two, 420 self.assertTrue(row_one >= row_two,
593 "Descending sort applied but row 0 is " 421 "Descending sort applied but row 0 is "
594 "greater than row 1") 422 "greater than row 1 %s %s" %
423 (column['field_name'], name))
595 424
596 # If the two start rows are the same we haven't actually 425 # If the two start rows are the same we haven't actually
597 # changed the order 426 # changed the order