Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 5F168E00C0F; Tue, 8 Dec 2015 13:18:41 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [209.85.220.48 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id EBE0BE00C31 for ; Tue, 8 Dec 2015 13:18:06 -0800 (PST) Received: by pacej9 with SMTP id ej9so17874343pac.2 for ; Tue, 08 Dec 2015 13:18:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=897JwLSEZB8MEAh4QVInSPzP6U4VHUsQo/w4nOxoWlg=; b=XTdvceXhZOJufIfq+rFjKN+Ku8LoFHuJv9bZ619us5pRGH2DSPBwMb7w0i78Gh+hH7 QTmrmeJd0llyFcfRgy/UN2jJMLOBHMfYxj8dYJV9M5oFbio7RswzwCCzf1jLUaLsWxnK MTjm+s1I5ETjLx2BGNgYj5hxe5OCu4HK2UVVKmkb3N/vLrET0hKH8HuKySJd5ZfT8JOh ml7a2xQMQU4qVF+xMDIyNliTcy/JWpfHtx1EEcCCQg3JSWWjsCewAjdqZ02fuqn+z4/6 9+/R9EfU8PL8gr7/HjmSzVHO6IBCwtaQ1rW8Sol9eIvn1LyAvDc1vxea4ieCzP/bMPBE iGUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=897JwLSEZB8MEAh4QVInSPzP6U4VHUsQo/w4nOxoWlg=; b=LFze9e2w3Dh80qrnDFYa/yuYZIz0PHPrbD6ES3uZJX6AQj8W0MO+skMUu/oBtbiESm 89Q0myTjJyBIL8uozIOgXn6RAj//9he068yDuPJv0EcenymNVPTrKI+VVMOwO3yLsG52 LWr1o/5QVrUhQeJwOVGBw09mi6aFzIWzzu9+1aDkK0qYaEib2VSLLy7wV3EBRAidXLo0 C3l86xY2OtANxu09xQjUnru1MtfNK4IT3kJUAk8aQ1x/oOFyR4ftR8g77wcFJRuwkgI2 vG3JONbHp3ko/TyEcyikJXSIwH9ilDNxldMfn9kL2MSpm1MjAn4tEZku8xRxLESgYZP2 0DZw== X-Gm-Message-State: ALoCoQnk55qk1v3I9JJnFXrvgbdKmkwYcCaK5OOapzBRmbfkCgXv0KWyU2tszPrcidJSRs7AGfLay+kvSa8ck/Wb/U6KQBP2dQ== X-Received: by 10.66.150.228 with SMTP id ul4mr2989060pab.15.1449609486792; Tue, 08 Dec 2015 13:18:06 -0800 (PST) Received: from draco.ger.corp.intel.com ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id v64sm6675766pfi.50.2015.12.08.13.18.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Dec 2015 13:18:05 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Tue, 8 Dec 2015 21:16:20 +0000 Message-Id: <1449609380-11073-35-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> References: <1449609380-11073-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 34/34] toaster: toastergui tests Add addtional data to the setUp for new tables X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2015 21:18:41 -0000 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. Signed-off-by: Michael Wood --- bitbake/lib/toaster/toastergui/tests.py | 92 ++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 25 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index d0e4676..0ec7a03 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py @@ -60,7 +60,8 @@ class ViewTests(TestCase): build = Build.objects.create(project=self.project, started_on=now, - completed_on=now) + completed_on=now, + outcome=Build.SUCCEEDED) layersrc = LayerSource.objects.create(sourcetype=LayerSource.TYPE_IMPORTED) self.priority = ReleaseLayerSourcePriority.objects.create(release=release, @@ -128,23 +129,34 @@ class ViewTests(TestCase): self.customr = CustomImageRecipe.objects.create(\ name="custom recipe", project=self.project, base_recipe=self.recipe1, + file_path="custr", layer_version=lver_custom) - CustomImageRecipe.objects.create(name="z custom recipe", - project=self.project, - base_recipe=self.recipe1) - self.package = Package.objects.create(name='pkg1', size=999, recipe=self.recipe1, + license="HHH", build=build) - Package.objects.create(name='zpkg1', recipe=self.recipe1, build=build) + Package.objects.create(name='A pkg1', + size=777, + recipe=self.recipe1, + build=build) + + Package.objects.create(name='zpkg1', + recipe=self.recipe1, + build=build, + size=4, + license="ZZ") self.project_package = ProjectPackage.objects.create( - name="ppkg1", + name="A pkg", recipe=self.recipe1, - project=self.project) + project=self.project, + size=10, + license="AAA") + + self.customr.appends_set.add(self.project_package) # recipe with project for testing AvailableRecipe table self.recipe2 = Recipe.objects.create(layer_source=layersrc, @@ -157,6 +169,20 @@ class ViewTests(TestCase): section="Z section", file_path='/home/foo') + # additional package for the sorting for the SelectPackagesTable + project_package_two = ProjectPackage.objects.create(name="ZZ pkg", + size=5, + recipe=self.recipe2, + project=self.project) + + self.customr.appends_set.add(project_package_two) + + Package.objects.create(name='one1', + recipe=self.recipe2, + build=build, + size=2, + license="L") + Recipe.objects.create(layer_source=layersrc, is_image=True, name="Test image one", @@ -168,17 +194,27 @@ class ViewTests(TestCase): file_path="/one/", layer_version=self.lver) - Recipe.objects.create(layer_source=layersrc, - is_image=True, - name="Z Test image two", - version="1.3", - summary="two image recipe", - description="recipe two", - section="B", - license="Z", - file_path="/two/", - layer_version=lver_two) + zrecipe = Recipe.objects.create(layer_source=layersrc, + is_image=True, + name="Z Test image two", + version="1.3", + summary="two image recipe", + description="recipe two", + section="B", + license="Z", + file_path="/two/", + layer_version=lver_two) + CustomImageRecipe.objects.create(name="z custom recipe", + project=self.project, + base_recipe=zrecipe, + file_path="zzzz", + layer_version=lver_custom) + + # Packages in PackagesTable requre that the recipe has been built so + # we need to create a target and build pair + target = Target.objects.create(target=self.recipe1.name, + build=build) @@ -390,14 +426,17 @@ class ViewTests(TestCase): self.assertEqual(self.customr.appends_set.first().name, self.project_package.name) # delete it + to_delete = self.customr.appends_set.first().pk del_url = reverse('xhr_customrecipe_packages', - args=(self.customr.id, - self.customr.appends_set.first().id)) + args=(self.customr.id, to_delete)) response = self.client.delete(del_url) self.assertEqual(response.status_code, 200) self.assertEqual(json.loads(response.content), {"error": "ok"}) - self.assertFalse(self.customr.includes_set.all()) + all_packages = self.customr.get_all_packages().values_list('pk', + flat=True) + + self.assertFalse(to_delete in all_packages) # delete invalid package to test error condition del_url = reverse('xhr_customrecipe_packages', args=(self.customr.id, @@ -439,8 +478,8 @@ class ViewTests(TestCase): row2 = next(x for x in rows if x['name'] == self.recipe2.name) self.assertEqual(response.status_code, 200, 'should be 200 OK status') - # self.recipe1 + self.recipe2 + self.customr = 3 - self.assertEqual(len(rows), 3, 'should be 3 recipes') + # All recipes in the setUp + self.assertEqual(len(rows), 5, 'should be 5 recipes') # check other columns have been populated correctly self.assertEqual(row1['name'], self.recipe1.name) @@ -458,6 +497,7 @@ class ViewTests(TestCase): def test_toaster_tables(self): """Test all ToasterTables instances""" + current_recipes = self.project.get_available_recipes() def get_data(table, options={}): """Send a request and parse the json response""" @@ -468,7 +508,9 @@ class ViewTests(TestCase): response = table.get(request, pid=self.project.id, layerid=self.lver.pk, - recipeid=self.recipe1.pk) + recipeid=self.recipe1.pk, + recipe_id=self.recipe1.pk, + custrecipeid=self.customr.pk) return json.loads(response.content) # Get a list of classes in tables module @@ -487,7 +529,7 @@ class ViewTests(TestCase): all_data = get_data(table) self.assertTrue(len(all_data['rows']) > 1, - "Cannot test on a table with < 1 row") + "Cannot test on a %s table with < 1 row" % name) if table.default_orderby: row_one = all_data['rows'][0][table.default_orderby.strip("-")] -- 2.1.4