diff options
author | Elliot Smith <elliot.smith@intel.com> | 2015-10-14 13:29:09 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-16 14:13:24 +0100 |
commit | 3c4c984e3356b1bb23d70e25fcd916d91d5a6284 (patch) | |
tree | ac843f18794b18eeaa261495d2a0b0076efc9f2d /bitbake/lib/toaster | |
parent | 3ba43f26eeea9bd76d05285bcb5a3f3aac70a573 (diff) | |
download | poky-3c4c984e3356b1bb23d70e25fcd916d91d5a6284.tar.gz |
bitbake: toaster: Reorganise and lint tests
Get test suite ready to accommodate new tests for how command line
builds are shown on various pages.
(Bitbake rev: 1ee1fc5dcdbb26c9f6e04b7719d7196083212d4c)
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster')
-rw-r--r-- | bitbake/lib/toaster/toastergui/tests.py | 83 |
1 files changed, 49 insertions, 34 deletions
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index e652b987a6..9156cc8952 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py | |||
@@ -21,23 +21,20 @@ | |||
21 | 21 | ||
22 | """Test cases for Toaster GUI and ReST.""" | 22 | """Test cases for Toaster GUI and ReST.""" |
23 | 23 | ||
24 | import re | ||
25 | |||
26 | from django.test import TestCase | 24 | from django.test import TestCase |
27 | from django.test.client import RequestFactory | 25 | from django.test.client import RequestFactory |
28 | from django.core.urlresolvers import reverse | 26 | from django.core.urlresolvers import reverse |
29 | from django.utils import timezone | 27 | from django.utils import timezone |
30 | 28 | ||
31 | from orm.models import Project, Release, BitbakeVersion, Build, Package | 29 | from orm.models import Project, Release, BitbakeVersion, Package |
32 | from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build | 30 | from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build |
33 | from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target | 31 | from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target |
34 | from orm.models import CustomImageRecipe | 32 | from orm.models import CustomImageRecipe |
35 | from orm.models import Branch | 33 | from orm.models import Branch |
36 | 34 | ||
37 | from toastergui.tables import SoftwareRecipesTable | 35 | from toastergui.tables import SoftwareRecipesTable |
38 | from django.utils import timezone | ||
39 | import json | ||
40 | from bs4 import BeautifulSoup | 36 | from bs4 import BeautifulSoup |
37 | import json | ||
41 | import re | 38 | import re |
42 | 39 | ||
43 | PROJECT_NAME = "test project" | 40 | PROJECT_NAME = "test project" |
@@ -72,11 +69,11 @@ class ViewTests(TestCase): | |||
72 | up_branch=branch) | 69 | up_branch=branch) |
73 | 70 | ||
74 | self.recipe1 = Recipe.objects.create(layer_source=layersrc, | 71 | self.recipe1 = Recipe.objects.create(layer_source=layersrc, |
75 | name="base-recipe", | 72 | name="base-recipe", |
76 | version="1.2", | 73 | version="1.2", |
77 | summary="one recipe", | 74 | summary="one recipe", |
78 | description="recipe", | 75 | description="recipe", |
79 | layer_version=lver) | 76 | layer_version=lver) |
80 | 77 | ||
81 | Machine.objects.create(layer_version=lver, name="wisk", | 78 | Machine.objects.create(layer_version=lver, name="wisk", |
82 | description="wisking machine") | 79 | description="wisking machine") |
@@ -337,11 +334,7 @@ class ViewTests(TestCase): | |||
337 | 334 | ||
338 | rows = data['rows'] | 335 | rows = data['rows'] |
339 | row1 = next(x for x in rows if x['name'] == self.recipe1.name) | 336 | row1 = next(x for x in rows if x['name'] == self.recipe1.name) |
340 | row1_btns = row1['static:add-del-layers'] | ||
341 | row1_btns_data = row1['add-del-layers'] | ||
342 | row2 = next(x for x in rows if x['name'] == self.recipe2.name) | 337 | row2 = next(x for x in rows if x['name'] == self.recipe2.name) |
343 | row2_btns = row2['static:add-del-layers'] | ||
344 | row2_btns_data = row2['add-del-layers'] | ||
345 | 338 | ||
346 | self.assertEqual(response.status_code, 200, 'should be 200 OK status') | 339 | self.assertEqual(response.status_code, 200, 'should be 200 OK status') |
347 | self.assertEqual(len(rows), 2, 'should be 2 recipes') | 340 | self.assertEqual(len(rows), 2, 'should be 2 recipes') |
@@ -472,7 +465,7 @@ class ProjectsPageTests(TestCase): | |||
472 | self.assertTrue(self.PROJECT_NAME in response.content, | 465 | self.assertTrue(self.PROJECT_NAME in response.content, |
473 | 'default project "cli builds" should be in page') | 466 | 'default project "cli builds" should be in page') |
474 | 467 | ||
475 | class ProjectBuildsDisplayTest(TestCase): | 468 | class ProjectBuildsPageTests(TestCase): |
476 | """ Test data at /project/X/builds is displayed correctly """ | 469 | """ Test data at /project/X/builds is displayed correctly """ |
477 | 470 | ||
478 | def setUp(self): | 471 | def setUp(self): |
@@ -517,6 +510,7 @@ class ProjectBuildsDisplayTest(TestCase): | |||
517 | } | 510 | } |
518 | 511 | ||
519 | def _get_rows_for_project(self, project_id): | 512 | def _get_rows_for_project(self, project_id): |
513 | """ Helper to retrieve HTML rows for a project """ | ||
520 | url = reverse("projectbuilds", args=(project_id,)) | 514 | url = reverse("projectbuilds", args=(project_id,)) |
521 | response = self.client.get(url, follow=True) | 515 | response = self.client.get(url, follow=True) |
522 | soup = BeautifulSoup(response.content) | 516 | soup = BeautifulSoup(response.content) |
@@ -524,52 +518,73 @@ class ProjectBuildsDisplayTest(TestCase): | |||
524 | 518 | ||
525 | def test_show_builds_for_project(self): | 519 | def test_show_builds_for_project(self): |
526 | """ Builds for a project should be displayed """ | 520 | """ Builds for a project should be displayed """ |
527 | build1a = Build.objects.create(**self.project1_build_success) | 521 | Build.objects.create(**self.project1_build_success) |
528 | build1b = Build.objects.create(**self.project1_build_success) | 522 | Build.objects.create(**self.project1_build_success) |
529 | build_rows = self._get_rows_for_project(self.project1.id) | 523 | build_rows = self._get_rows_for_project(self.project1.id) |
530 | self.assertEqual(len(build_rows), 2) | 524 | self.assertEqual(len(build_rows), 2) |
531 | 525 | ||
532 | def test_show_builds_for_project_only(self): | 526 | def test_show_builds_project_only(self): |
533 | """ Builds for other projects should be excluded """ | 527 | """ Builds for other projects should be excluded """ |
534 | build1a = Build.objects.create(**self.project1_build_success) | 528 | Build.objects.create(**self.project1_build_success) |
535 | build1b = Build.objects.create(**self.project1_build_success) | 529 | Build.objects.create(**self.project1_build_success) |
536 | build1c = Build.objects.create(**self.project1_build_success) | 530 | Build.objects.create(**self.project1_build_success) |
537 | 531 | ||
538 | # shouldn't see these two | 532 | # shouldn't see these two |
539 | build2a = Build.objects.create(**self.project2_build_success) | 533 | Build.objects.create(**self.project2_build_success) |
540 | build2b = Build.objects.create(**self.project2_build_in_progress) | 534 | Build.objects.create(**self.project2_build_in_progress) |
541 | 535 | ||
542 | build_rows = self._get_rows_for_project(self.project1.id) | 536 | build_rows = self._get_rows_for_project(self.project1.id) |
543 | self.assertEqual(len(build_rows), 3) | 537 | self.assertEqual(len(build_rows), 3) |
544 | 538 | ||
545 | def test_show_builds_exclude_in_progress(self): | 539 | def test_builds_exclude_in_progress(self): |
546 | """ "in progress" builds should not be shown """ | 540 | """ "in progress" builds should not be shown """ |
547 | build1a = Build.objects.create(**self.project1_build_success) | 541 | Build.objects.create(**self.project1_build_success) |
548 | build1b = Build.objects.create(**self.project1_build_success) | 542 | Build.objects.create(**self.project1_build_success) |
549 | 543 | ||
550 | # shouldn't see this one | 544 | # shouldn't see this one |
551 | build1c = Build.objects.create(**self.project1_build_in_progress) | 545 | Build.objects.create(**self.project1_build_in_progress) |
552 | 546 | ||
553 | # shouldn't see these two either, as they belong to a different project | 547 | # shouldn't see these two either, as they belong to a different project |
554 | build2a = Build.objects.create(**self.project2_build_success) | 548 | Build.objects.create(**self.project2_build_success) |
555 | build2b = Build.objects.create(**self.project2_build_in_progress) | 549 | Build.objects.create(**self.project2_build_in_progress) |
556 | 550 | ||
557 | build_rows = self._get_rows_for_project(self.project1.id) | 551 | build_rows = self._get_rows_for_project(self.project1.id) |
558 | self.assertEqual(len(build_rows), 2) | 552 | self.assertEqual(len(build_rows), 2) |
559 | 553 | ||
560 | def test_show_tasks_in_projectbuilds(self): | 554 | def test_tasks_in_projectbuilds(self): |
555 | """ Task should be shown as suffix on build name """ | ||
561 | build = Build.objects.create(**self.project1_build_success) | 556 | build = Build.objects.create(**self.project1_build_success) |
562 | target = Target.objects.create(build=build, target='bash', | 557 | Target.objects.create(build=build, target='bash', task='clean') |
563 | task='clean') | ||
564 | url = reverse("projectbuilds", args=(self.project1.id,)) | 558 | url = reverse("projectbuilds", args=(self.project1.id,)) |
565 | response = self.client.get(url, follow=True) | 559 | response = self.client.get(url, follow=True) |
566 | result = re.findall('^ +bash:clean$', response.content, re.MULTILINE) | 560 | result = re.findall('^ +bash:clean$', response.content, re.MULTILINE) |
567 | self.assertEqual(len(result), 2) | 561 | self.assertEqual(len(result), 2) |
568 | 562 | ||
563 | class AllBuildsPageTests(TestCase): | ||
564 | """ Tests for all builds page """ | ||
565 | |||
566 | def setUp(self): | ||
567 | bbv = BitbakeVersion.objects.create(name="bbv1", giturl="/tmp/", | ||
568 | branch="master", dirpath="") | ||
569 | release = Release.objects.create(name="release1", | ||
570 | bitbake_version=bbv) | ||
571 | self.project1 = Project.objects.create_project(name=PROJECT_NAME, | ||
572 | release=release) | ||
573 | |||
574 | # parameters for builds to associate with the projects | ||
575 | now = timezone.now() | ||
576 | |||
577 | self.project1_build_success = { | ||
578 | "project": self.project1, | ||
579 | "started_on": now, | ||
580 | "completed_on": now, | ||
581 | "outcome": Build.SUCCEEDED | ||
582 | } | ||
583 | |||
569 | def test_show_tasks_in_allbuilds(self): | 584 | def test_show_tasks_in_allbuilds(self): |
585 | """ Task should be shown as suffix on build name """ | ||
570 | build = Build.objects.create(**self.project1_build_success) | 586 | build = Build.objects.create(**self.project1_build_success) |
571 | target = Target.objects.create(build=build, target='bash', | 587 | Target.objects.create(build=build, target='bash', task='clean') |
572 | task='clean') | ||
573 | url = reverse("all-builds") | 588 | url = reverse("all-builds") |
574 | response = self.client.get(url, follow=True) | 589 | response = self.client.get(url, follow=True) |
575 | result = re.findall('bash:clean', response.content, re.MULTILINE) | 590 | result = re.findall('bash:clean', response.content, re.MULTILINE) |