diff options
author | Michael Wood <michael.g.wood@intel.com> | 2016-05-26 16:12:25 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-06-15 08:35:04 +0100 |
commit | 82722cb5645cfee8007adc0076315ea63f2bda15 (patch) | |
tree | 928012ef4b2e9f9d44515f3e873a91c96fe6c21e /bitbake/lib/toaster/toastergui/tests.py | |
parent | c42f1cc81dda06ee39d1f0dd76a14da17b9c7f54 (diff) | |
download | poky-82722cb5645cfee8007adc0076315ea63f2bda15.tar.gz |
bitbake: toaster: tests Add new build tables to tests
- Add new build tables to be tested
- Add required data into the fixture and clean up a few empty fields
- Fix the SoftwareRecipesTable specific test so as not to rely on two
particular defined recipes
(Bitbake rev: 7cf23671659666b27b5629fecd5f947f9bdb94e0)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/tests.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/tests.py | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index 869c39d84c..9af101804f 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py | |||
@@ -25,6 +25,7 @@ from django.test import TestCase | |||
25 | from django.test.client import RequestFactory | 25 | from django.test.client import RequestFactory |
26 | from django.core.urlresolvers import reverse | 26 | from django.core.urlresolvers import reverse |
27 | from django.utils import timezone | 27 | from django.utils import timezone |
28 | from django.db.models import Q | ||
28 | 29 | ||
29 | from orm.models import Project, Release, BitbakeVersion, Package, LogMessage | 30 | from orm.models import Project, Release, BitbakeVersion, Package, LogMessage |
30 | from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build | 31 | from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build |
@@ -57,7 +58,6 @@ class ViewTests(TestCase): | |||
57 | 58 | ||
58 | self.project = Project.objects.first() | 59 | self.project = Project.objects.first() |
59 | self.recipe1 = Recipe.objects.get(pk=2) | 60 | self.recipe1 = Recipe.objects.get(pk=2) |
60 | self.recipe2 = Recipe.objects.last() | ||
61 | self.customr = CustomImageRecipe.objects.first() | 61 | self.customr = CustomImageRecipe.objects.first() |
62 | self.cust_package = CustomImagePackage.objects.first() | 62 | self.cust_package = CustomImagePackage.objects.first() |
63 | self.package = Package.objects.first() | 63 | self.package = Package.objects.first() |
@@ -311,7 +311,6 @@ class ViewTests(TestCase): | |||
311 | 311 | ||
312 | self.assertEqual(response.status_code, 200) | 312 | self.assertEqual(response.status_code, 200) |
313 | 313 | ||
314 | |||
315 | def test_software_recipes_table(self): | 314 | def test_software_recipes_table(self): |
316 | """Test structure returned for Software RecipesTable""" | 315 | """Test structure returned for Software RecipesTable""" |
317 | table = SoftwareRecipesTable() | 316 | table = SoftwareRecipesTable() |
@@ -319,27 +318,35 @@ class ViewTests(TestCase): | |||
319 | response = table.get(request, pid=self.project.id) | 318 | response = table.get(request, pid=self.project.id) |
320 | data = json.loads(response.content) | 319 | data = json.loads(response.content) |
321 | 320 | ||
321 | recipes = Recipe.objects.filter(Q(is_image=False)) | ||
322 | self.assertTrue(len(recipes) > 1, | ||
323 | "Need more than one software recipe to test " | ||
324 | "SoftwareRecipesTable") | ||
325 | |||
326 | recipe1 = recipes[0] | ||
327 | recipe2 = recipes[1] | ||
328 | |||
322 | rows = data['rows'] | 329 | rows = data['rows'] |
323 | row1 = next(x for x in rows if x['name'] == self.recipe1.name) | 330 | row1 = next(x for x in rows if x['name'] == recipe1.name) |
324 | row2 = next(x for x in rows if x['name'] == self.recipe2.name) | 331 | row2 = next(x for x in rows if x['name'] == recipe2.name) |
325 | 332 | ||
326 | self.assertEqual(response.status_code, 200, 'should be 200 OK status') | 333 | self.assertEqual(response.status_code, 200, 'should be 200 OK status') |
327 | 334 | ||
328 | # check other columns have been populated correctly | 335 | # check other columns have been populated correctly |
329 | self.assertTrue(self.recipe1.name in row1['name']) | 336 | self.assertTrue(recipe1.name in row1['name']) |
330 | self.assertTrue(self.recipe1.version in row1['version']) | 337 | self.assertTrue(recipe1.version in row1['version']) |
331 | self.assertTrue(self.recipe1.description in | 338 | self.assertTrue(recipe1.description in |
332 | row1['get_description_or_summary']) | 339 | row1['get_description_or_summary']) |
333 | 340 | ||
334 | self.assertTrue(self.recipe1.layer_version.layer.name in | 341 | self.assertTrue(recipe1.layer_version.layer.name in |
335 | row1['layer_version__layer__name']) | 342 | row1['layer_version__layer__name']) |
336 | 343 | ||
337 | self.assertTrue(self.recipe2.name in row2['name']) | 344 | self.assertTrue(recipe2.name in row2['name']) |
338 | self.assertTrue(self.recipe2.version in row2['version']) | 345 | self.assertTrue(recipe2.version in row2['version']) |
339 | self.assertTrue(self.recipe2.description in | 346 | self.assertTrue(recipe2.description in |
340 | row2['get_description_or_summary']) | 347 | row2['get_description_or_summary']) |
341 | 348 | ||
342 | self.assertTrue(self.recipe2.layer_version.layer.name in | 349 | self.assertTrue(recipe2.layer_version.layer.name in |
343 | row2['layer_version__layer__name']) | 350 | row2['layer_version__layer__name']) |
344 | 351 | ||
345 | def test_toaster_tables(self): | 352 | def test_toaster_tables(self): |
@@ -360,7 +367,9 @@ class ViewTests(TestCase): | |||
360 | 'layerid': self.lver.pk, | 367 | 'layerid': self.lver.pk, |
361 | 'recipeid': self.recipe1.pk, | 368 | 'recipeid': self.recipe1.pk, |
362 | 'recipe_id': image_recipe.pk, | 369 | 'recipe_id': image_recipe.pk, |
363 | 'custrecipeid': self.customr.pk} | 370 | 'custrecipeid': self.customr.pk, |
371 | 'build_id': 1, | ||
372 | 'target_id': 1} | ||
364 | 373 | ||
365 | response = table.get(request, **args) | 374 | response = table.get(request, **args) |
366 | return json.loads(response.content) | 375 | return json.loads(response.content) |
@@ -386,11 +395,14 @@ class ViewTests(TestCase): | |||
386 | 395 | ||
387 | # Get a list of classes in tables module | 396 | # Get a list of classes in tables module |
388 | tables = inspect.getmembers(toastergui.tables, inspect.isclass) | 397 | tables = inspect.getmembers(toastergui.tables, inspect.isclass) |
398 | tables.extend(inspect.getmembers(toastergui.buildtables, | ||
399 | inspect.isclass)) | ||
389 | 400 | ||
390 | for name, table_cls in tables: | 401 | for name, table_cls in tables: |
391 | # Filter out the non ToasterTables from the tables module | 402 | # Filter out the non ToasterTables from the tables module |
392 | if not issubclass(table_cls, toastergui.widgets.ToasterTable) or \ | 403 | if not issubclass(table_cls, toastergui.widgets.ToasterTable) or \ |
393 | table_cls == toastergui.widgets.ToasterTable: | 404 | table_cls == toastergui.widgets.ToasterTable or \ |
405 | 'Mixin' in name: | ||
394 | continue | 406 | continue |
395 | 407 | ||
396 | # Get the table data without any options, this also does the | 408 | # Get the table data without any options, this also does the |