From 82722cb5645cfee8007adc0076315ea63f2bda15 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Thu, 26 May 2016 16:12:25 +0100 Subject: 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 Signed-off-by: Richard Purdie --- .../fixtures/toastergui-unittest-data.xml | 91 ++++++++++++++++------ bitbake/lib/toaster/toastergui/tests.py | 40 ++++++---- 2 files changed, 94 insertions(+), 37 deletions(-) (limited to 'bitbake') diff --git a/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml b/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml index cf35be4be6..213bf0f675 100644 --- a/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml +++ b/bitbake/lib/toaster/toastergui/fixtures/toastergui-unittest-data.xml @@ -82,9 +82,8 @@ 1 a image recipe - False - 0 - + True + 290 2 @@ -118,9 +117,9 @@ 1 - 2 + 1 f pkg - + f @@ -297,6 +296,16 @@ False + + + g recipe + 1.2.3 + 3 + g license + /g + False + + @@ -353,8 +362,6 @@ 1 - - master @@ -363,13 +370,7 @@ a layer - /tmp/ - - - - - 1 @@ -378,21 +379,16 @@ z layer git://two/ - - - - - - + 1 1 1 1 - - master + master + abcdef123 /tmp/ 0 / @@ -405,8 +401,22 @@ 1 - - master + testing-branch + 9876fedcba + + 0 + / + + + + 1 + 2 + 1 + + + 1 + testing-branch + 9876fedcba 0 / @@ -443,4 +453,39 @@ + + + 1 + 1 + False + -1 + abcdef123 + 34/wefw.tar + 1 + a_do_compile + 100 + 10 + 11 + 12 + 10.1 + 10.2 + 3 + + + 1 + 2 + True + 2 + 85bccb7802fd5f48 + 85/sstarpm.tgz + 2 + z_do_package_write_rpm + 245 + 12424 + 23423 + 83943 + 20394.3 + 5363.3 + 1 + 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 from django.test.client import RequestFactory from django.core.urlresolvers import reverse from django.utils import timezone +from django.db.models import Q from orm.models import Project, Release, BitbakeVersion, Package, LogMessage from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build @@ -57,7 +58,6 @@ class ViewTests(TestCase): self.project = Project.objects.first() self.recipe1 = Recipe.objects.get(pk=2) - self.recipe2 = Recipe.objects.last() self.customr = CustomImageRecipe.objects.first() self.cust_package = CustomImagePackage.objects.first() self.package = Package.objects.first() @@ -311,7 +311,6 @@ class ViewTests(TestCase): self.assertEqual(response.status_code, 200) - def test_software_recipes_table(self): """Test structure returned for Software RecipesTable""" table = SoftwareRecipesTable() @@ -319,27 +318,35 @@ class ViewTests(TestCase): response = table.get(request, pid=self.project.id) data = json.loads(response.content) + recipes = Recipe.objects.filter(Q(is_image=False)) + self.assertTrue(len(recipes) > 1, + "Need more than one software recipe to test " + "SoftwareRecipesTable") + + recipe1 = recipes[0] + recipe2 = recipes[1] + rows = data['rows'] - row1 = next(x for x in rows if x['name'] == self.recipe1.name) - row2 = next(x for x in rows if x['name'] == self.recipe2.name) + row1 = next(x for x in rows if x['name'] == recipe1.name) + row2 = next(x for x in rows if x['name'] == recipe2.name) self.assertEqual(response.status_code, 200, 'should be 200 OK status') # check other columns have been populated correctly - self.assertTrue(self.recipe1.name in row1['name']) - self.assertTrue(self.recipe1.version in row1['version']) - self.assertTrue(self.recipe1.description in + self.assertTrue(recipe1.name in row1['name']) + self.assertTrue(recipe1.version in row1['version']) + self.assertTrue(recipe1.description in row1['get_description_or_summary']) - self.assertTrue(self.recipe1.layer_version.layer.name in + self.assertTrue(recipe1.layer_version.layer.name in row1['layer_version__layer__name']) - self.assertTrue(self.recipe2.name in row2['name']) - self.assertTrue(self.recipe2.version in row2['version']) - self.assertTrue(self.recipe2.description in + self.assertTrue(recipe2.name in row2['name']) + self.assertTrue(recipe2.version in row2['version']) + self.assertTrue(recipe2.description in row2['get_description_or_summary']) - self.assertTrue(self.recipe2.layer_version.layer.name in + self.assertTrue(recipe2.layer_version.layer.name in row2['layer_version__layer__name']) def test_toaster_tables(self): @@ -360,7 +367,9 @@ class ViewTests(TestCase): 'layerid': self.lver.pk, 'recipeid': self.recipe1.pk, 'recipe_id': image_recipe.pk, - 'custrecipeid': self.customr.pk} + 'custrecipeid': self.customr.pk, + 'build_id': 1, + 'target_id': 1} response = table.get(request, **args) return json.loads(response.content) @@ -386,11 +395,14 @@ class ViewTests(TestCase): # Get a list of classes in tables module tables = inspect.getmembers(toastergui.tables, inspect.isclass) + tables.extend(inspect.getmembers(toastergui.buildtables, + inspect.isclass)) for name, table_cls in tables: # Filter out the non ToasterTables from the tables module if not issubclass(table_cls, toastergui.widgets.ToasterTable) or \ - table_cls == toastergui.widgets.ToasterTable: + table_cls == toastergui.widgets.ToasterTable or \ + 'Mixin' in name: continue # Get the table data without any options, this also does the -- cgit 1.2.3-korg