summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-12-08 19:56:11 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 13:29:19 +0000
commit76c000801415597975724978d42763f4ac573c50 (patch)
tree65bd0430a93cc135b7674ce01cf99fd7eeb91873 /bitbake
parent70a078ee851b0408b68ddc13fbc7fbb658ce38df (diff)
downloadpoky-76c000801415597975724978d42763f4ac573c50.tar.gz
bitbake: toaster: toastergui tests Add addtional data to the setUp for new tables
Add additional data to the setUp to be able to test all the tables for Image Customisation. Also add the name of the table being tested to the num of rows assertion. (Bitbake rev: dfcbcf789cf3f0733ca26b0601fdf97ce4291674) 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>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/toastergui/tests.py91
1 files changed, 66 insertions, 25 deletions
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index bd5cb0f244..56a7d7e860 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -72,7 +72,8 @@ class ViewTests(TestCase):
72 72
73 build = Build.objects.create(project=self.project, 73 build = Build.objects.create(project=self.project,
74 started_on=now, 74 started_on=now,
75 completed_on=now) 75 completed_on=now,
76 outcome=Build.SUCCEEDED)
76 77
77 # for testing BuildsTable 78 # for testing BuildsTable
78 build1 = Build.objects.create(project=self.project, 79 build1 = Build.objects.create(project=self.project,
@@ -163,22 +164,33 @@ class ViewTests(TestCase):
163 self.customr = CustomImageRecipe.objects.create(\ 164 self.customr = CustomImageRecipe.objects.create(\
164 name="custom recipe", project=self.project, 165 name="custom recipe", project=self.project,
165 base_recipe=self.recipe1, 166 base_recipe=self.recipe1,
167 file_path="custr",
166 layer_version=lver_custom) 168 layer_version=lver_custom)
167 169
168 CustomImageRecipe.objects.create(name="z custom recipe",
169 project=self.project,
170 base_recipe=self.recipe1)
171
172 self.package = Package.objects.create(name='pkg1', 170 self.package = Package.objects.create(name='pkg1',
173 size=999, 171 size=999,
174 recipe=self.recipe1, 172 recipe=self.recipe1,
173 license="HHH",
175 build=build) 174 build=build)
176 175
177 Package.objects.create(name='zpkg1', recipe=self.recipe1, build=build) 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")
178 186
179 self.cust_package = CustomImagePackage.objects.create( 187 self.cust_package = CustomImagePackage.objects.create(
180 name="ppkg1", 188 name="A pkg",
181 recipe=self.recipe1) 189 recipe=self.recipe1,
190 size=10,
191 license="AAA")
192
193 self.customr.appends_set.add(self.cust_package)
182 194
183 # recipe with project for testing AvailableRecipe table 195 # recipe with project for testing AvailableRecipe table
184 self.recipe2 = Recipe.objects.create(layer_source=layersrc, 196 self.recipe2 = Recipe.objects.create(layer_source=layersrc,
@@ -191,6 +203,19 @@ class ViewTests(TestCase):
191 section="Z section", 203 section="Z section",
192 file_path='/home/foo') 204 file_path='/home/foo')
193 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
194 Recipe.objects.create(layer_source=layersrc, 219 Recipe.objects.create(layer_source=layersrc,
195 is_image=True, 220 is_image=True,
196 name="Test image one", 221 name="Test image one",
@@ -202,17 +227,27 @@ class ViewTests(TestCase):
202 file_path="/one/", 227 file_path="/one/",
203 layer_version=self.lver) 228 layer_version=self.lver)
204 229
205 Recipe.objects.create(layer_source=layersrc, 230 zrecipe = Recipe.objects.create(layer_source=layersrc,
206 is_image=True, 231 is_image=True,
207 name="Z Test image two", 232 name="Z Test image two",
208 version="1.3", 233 version="1.3",
209 summary="two image recipe", 234 summary="two image recipe",
210 description="recipe two", 235 description="recipe two",
211 section="B", 236 section="B",
212 license="Z", 237 license="Z",
213 file_path="/two/", 238 file_path="/two/",
214 layer_version=lver_two) 239 layer_version=lver_two)
215 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)
216 251
217 252
218 253
@@ -416,14 +451,17 @@ class ViewTests(TestCase):
416 self.assertEqual(self.customr.appends_set.first().name, 451 self.assertEqual(self.customr.appends_set.first().name,
417 self.cust_package.name) 452 self.cust_package.name)
418 # delete it 453 # delete it
454 to_delete = self.customr.appends_set.first().pk
419 del_url = reverse('xhr_customrecipe_packages', 455 del_url = reverse('xhr_customrecipe_packages',
420 args=(self.customr.id, 456 args=(self.customr.id, to_delete))
421 self.customr.appends_set.first().id))
422 457
423 response = self.client.delete(del_url) 458 response = self.client.delete(del_url)
424 self.assertEqual(response.status_code, 200) 459 self.assertEqual(response.status_code, 200)
425 self.assertEqual(json.loads(response.content), {"error": "ok"}) 460 self.assertEqual(json.loads(response.content), {"error": "ok"})
426 self.assertFalse(self.customr.includes_set.all()) 461 all_packages = self.customr.get_all_packages().values_list('pk',
462 flat=True)
463
464 self.assertFalse(to_delete in all_packages)
427 # delete invalid package to test error condition 465 # delete invalid package to test error condition
428 del_url = reverse('xhr_customrecipe_packages', 466 del_url = reverse('xhr_customrecipe_packages',
429 args=(self.customr.id, 467 args=(self.customr.id,
@@ -465,8 +503,8 @@ class ViewTests(TestCase):
465 row2 = next(x for x in rows if x['name'] == self.recipe2.name) 503 row2 = next(x for x in rows if x['name'] == self.recipe2.name)
466 504
467 self.assertEqual(response.status_code, 200, 'should be 200 OK status') 505 self.assertEqual(response.status_code, 200, 'should be 200 OK status')
468 # self.recipe1 + self.recipe2 + self.customr = 3 506 # All recipes in the setUp
469 self.assertEqual(len(rows), 3, 'should be 3 recipes') 507 self.assertEqual(len(rows), 5, 'should be 5 recipes')
470 508
471 # check other columns have been populated correctly 509 # check other columns have been populated correctly
472 self.assertEqual(row1['name'], self.recipe1.name) 510 self.assertEqual(row1['name'], self.recipe1.name)
@@ -484,6 +522,7 @@ class ViewTests(TestCase):
484 522
485 def test_toaster_tables(self): 523 def test_toaster_tables(self):
486 """Test all ToasterTables instances""" 524 """Test all ToasterTables instances"""
525 current_recipes = self.project.get_available_recipes()
487 526
488 def get_data(table, options={}): 527 def get_data(table, options={}):
489 """Send a request and parse the json response""" 528 """Send a request and parse the json response"""
@@ -494,7 +533,9 @@ class ViewTests(TestCase):
494 response = table.get(request, 533 response = table.get(request,
495 pid=self.project.id, 534 pid=self.project.id,
496 layerid=self.lver.pk, 535 layerid=self.lver.pk,
497 recipeid=self.recipe1.pk) 536 recipeid=self.recipe1.pk,
537 recipe_id=self.recipe1.pk,
538 custrecipeid=self.customr.pk)
498 return json.loads(response.content) 539 return json.loads(response.content)
499 540
500 # Get a list of classes in tables module 541 # Get a list of classes in tables module
@@ -513,7 +554,7 @@ class ViewTests(TestCase):
513 all_data = get_data(table) 554 all_data = get_data(table)
514 555
515 self.assertTrue(len(all_data['rows']) > 1, 556 self.assertTrue(len(all_data['rows']) > 1,
516 "Cannot test on the table %s with < 1 row" % name) 557 "Cannot test on a %s table with < 1 row" % name)
517 558
518 if table.default_orderby: 559 if table.default_orderby:
519 row_one = all_data['rows'][0][table.default_orderby.strip("-")] 560 row_one = all_data['rows'][0][table.default_orderby.strip("-")]