Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 37BC7E00C87; Tue, 6 Oct 2015 04:21:33 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [134.134.136.24 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 771FDE00C3C for ; Tue, 6 Oct 2015 04:21:31 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 06 Oct 2015 04:21:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,643,1437462000"; d="scan'208";a="820419290" Received: from blynch-mobl1.ger.corp.intel.com (HELO lp.ger.corp.intel.com) ([10.252.3.31]) by orsmga002.jf.intel.com with ESMTP; 06 Oct 2015 04:21:30 -0700 From: Elliot Smith To: toaster@yoctoproject.org Date: Tue, 6 Oct 2015 12:21:11 +0100 Message-Id: <1444130481-25705-3-git-send-email-elliot.smith@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1444130481-25705-1-git-send-email-elliot.smith@intel.com> References: <1444130481-25705-1-git-send-email-elliot.smith@intel.com> Subject: [review-request][PATCH 01/10] toaster: Reorganise and lint tests 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, 06 Oct 2015 11:21:33 -0000 Get test suite ready to accommodate new tests for how command line builds are shown on various pages. Signed-off-by: Elliot Smith --- bitbake/lib/toaster/toastergui/tests.py | 83 +++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 34 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index 95790a2..7b1f9b5 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py @@ -21,23 +21,20 @@ """Test cases for Toaster GUI and ReST.""" -import re - from django.test import TestCase from django.test.client import RequestFactory from django.core.urlresolvers import reverse from django.utils import timezone -from orm.models import Project, Release, BitbakeVersion, Build, Package +from orm.models import Project, Release, BitbakeVersion, Package from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target from orm.models import CustomImageRecipe from orm.models import Branch from toastergui.tables import SoftwareRecipesTable -from django.utils import timezone -import json from bs4 import BeautifulSoup +import json import re PROJECT_NAME = "test project" @@ -72,11 +69,11 @@ class ViewTests(TestCase): up_branch=branch) self.recipe1 = Recipe.objects.create(layer_source=layersrc, - name="base-recipe", - version="1.2", - summary="one recipe", - description="recipe", - layer_version=lver) + name="base-recipe", + version="1.2", + summary="one recipe", + description="recipe", + layer_version=lver) Machine.objects.create(layer_version=lver, name="wisk", description="wisking machine") @@ -337,11 +334,7 @@ class ViewTests(TestCase): rows = data['rows'] row1 = next(x for x in rows if x['name'] == self.recipe1.name) - row1_btns = row1['static:add-del-layers'] - row1_btns_data = row1['add-del-layers'] row2 = next(x for x in rows if x['name'] == self.recipe2.name) - row2_btns = row2['static:add-del-layers'] - row2_btns_data = row2['add-del-layers'] self.assertEqual(response.status_code, 200, 'should be 200 OK status') self.assertEqual(len(rows), 2, 'should be 2 recipes') @@ -472,7 +465,7 @@ class ProjectsPageTests(TestCase): self.assertTrue(self.PROJECT_NAME in response.content, 'default project "cli builds" should be in page') -class ProjectBuildsDisplayTest(TestCase): +class ProjectBuildsPageTests(TestCase): """ Test data at /project/X/builds is displayed correctly """ def setUp(self): @@ -517,6 +510,7 @@ class ProjectBuildsDisplayTest(TestCase): } def _get_rows_for_project(self, project_id): + """ Helper to retrieve HTML rows for a project """ url = reverse("projectbuilds", args=(project_id,)) response = self.client.get(url, follow=True) soup = BeautifulSoup(response.content) @@ -524,52 +518,73 @@ class ProjectBuildsDisplayTest(TestCase): def test_show_builds_for_project(self): """ Builds for a project should be displayed """ - build1a = Build.objects.create(**self.project1_build_success) - build1b = Build.objects.create(**self.project1_build_success) + Build.objects.create(**self.project1_build_success) + Build.objects.create(**self.project1_build_success) build_rows = self._get_rows_for_project(self.project1.id) self.assertEqual(len(build_rows), 2) - def test_show_builds_for_project_only(self): + def test_show_builds_project_only(self): """ Builds for other projects should be excluded """ - build1a = Build.objects.create(**self.project1_build_success) - build1b = Build.objects.create(**self.project1_build_success) - build1c = Build.objects.create(**self.project1_build_success) + Build.objects.create(**self.project1_build_success) + Build.objects.create(**self.project1_build_success) + Build.objects.create(**self.project1_build_success) # shouldn't see these two - build2a = Build.objects.create(**self.project2_build_success) - build2b = Build.objects.create(**self.project2_build_in_progress) + Build.objects.create(**self.project2_build_success) + Build.objects.create(**self.project2_build_in_progress) build_rows = self._get_rows_for_project(self.project1.id) self.assertEqual(len(build_rows), 3) - def test_show_builds_exclude_in_progress(self): + def test_builds_exclude_in_progress(self): """ "in progress" builds should not be shown """ - build1a = Build.objects.create(**self.project1_build_success) - build1b = Build.objects.create(**self.project1_build_success) + Build.objects.create(**self.project1_build_success) + Build.objects.create(**self.project1_build_success) # shouldn't see this one - build1c = Build.objects.create(**self.project1_build_in_progress) + Build.objects.create(**self.project1_build_in_progress) # shouldn't see these two either, as they belong to a different project - build2a = Build.objects.create(**self.project2_build_success) - build2b = Build.objects.create(**self.project2_build_in_progress) + Build.objects.create(**self.project2_build_success) + Build.objects.create(**self.project2_build_in_progress) build_rows = self._get_rows_for_project(self.project1.id) self.assertEqual(len(build_rows), 2) - def test_show_tasks_in_projectbuilds(self): + def test_tasks_in_projectbuilds(self): + """ Task should be shown as suffix on build name """ build = Build.objects.create(**self.project1_build_success) - target = Target.objects.create(build=build, target='bash', - task='clean') + Target.objects.create(build=build, target='bash', task='clean') url = reverse("projectbuilds", args=(self.project1.id,)) response = self.client.get(url, follow=True) result = re.findall('^ +bash:clean$', response.content, re.MULTILINE) self.assertEqual(len(result), 2) +class AllBuildsPageTests(TestCase): + """ Tests for all builds page """ + + def setUp(self): + bbv = BitbakeVersion.objects.create(name="bbv1", giturl="/tmp/", + branch="master", dirpath="") + release = Release.objects.create(name="release1", + bitbake_version=bbv) + self.project1 = Project.objects.create_project(name=PROJECT_NAME, + release=release) + + # parameters for builds to associate with the projects + now = timezone.now() + + self.project1_build_success = { + "project": self.project1, + "started_on": now, + "completed_on": now, + "outcome": Build.SUCCEEDED + } + def test_show_tasks_in_allbuilds(self): + """ Task should be shown as suffix on build name """ build = Build.objects.create(**self.project1_build_success) - target = Target.objects.create(build=build, target='bash', - task='clean') + Target.objects.create(build=build, target='bash', task='clean') url = reverse("all-builds") response = self.client.get(url, follow=True) result = re.findall('bash:clean', response.content, re.MULTILINE) -- Elliot Smith Software Engineer Intel OTC --------------------------------------------------------------------- Intel Corporation (UK) Limited Registered No. 1134945 (England) Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.