diff options
author | Elliot Smith <elliot.smith@intel.com> | 2015-10-14 13:29:11 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-16 14:16:17 +0100 |
commit | b5624c77ed91d20f1ab4737a921baa908cf00646 (patch) | |
tree | f4d77082c13b46d2c1e07d2f299113dd7064848f /bitbake/lib/toaster/toastergui/tests.py | |
parent | 3c4c984e3356b1bb23d70e25fcd916d91d5a6284 (diff) | |
download | poky-b5624c77ed91d20f1ab4737a921baa908cf00646.tar.gz |
bitbake: toaster: Show 'not applicable' for default project machine and release
The machine and release for the default project should show as
'not applicable' on the all projects page, as that information
isn't available for command-line builds.
Modify the templates with some conditionals to check for the
default project row, plus some data-* attributes to mark
where that data is to make testing possible.
Add some tests for the all projects page to ensure that
the correct machine/release are still shown for non-default projects,
and 'not applicable' for the default project.
[YOCTO #8231]
(Bitbake rev: ce27b3fd728f0373aa1adc0d47baace264529b45)
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/toastergui/tests.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/tests.py | 108 |
1 files changed, 98 insertions, 10 deletions
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py index 9156cc8952..d278d63aa1 100644 --- a/bitbake/lib/toaster/toastergui/tests.py +++ b/bitbake/lib/toaster/toastergui/tests.py | |||
@@ -29,7 +29,7 @@ from django.utils import timezone | |||
29 | from orm.models import Project, Release, BitbakeVersion, Package | 29 | from orm.models import Project, Release, BitbakeVersion, Package |
30 | from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build | 30 | from orm.models import ReleaseLayerSourcePriority, LayerSource, Layer, Build |
31 | from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target | 31 | from orm.models import Layer_Version, Recipe, Machine, ProjectLayer, Target |
32 | from orm.models import CustomImageRecipe | 32 | from orm.models import CustomImageRecipe, ProjectVariable |
33 | from orm.models import Branch | 33 | from orm.models import Branch |
34 | 34 | ||
35 | from toastergui.tables import SoftwareRecipesTable | 35 | from toastergui.tables import SoftwareRecipesTable |
@@ -430,15 +430,43 @@ class LandingPageTests(TestCase): | |||
430 | class ProjectsPageTests(TestCase): | 430 | class ProjectsPageTests(TestCase): |
431 | """ Tests for projects page """ | 431 | """ Tests for projects page """ |
432 | 432 | ||
433 | PROJECT_NAME = 'cli builds' | 433 | MACHINE_NAME = 'delorean' |
434 | |||
435 | def _add_build_to_default_project(self): | ||
436 | """ Add a build to the default project (not used in all tests) """ | ||
437 | now = timezone.now() | ||
438 | build = Build.objects.create(project=self.default_project, | ||
439 | started_on=now, | ||
440 | completed_on=now) | ||
441 | build.save() | ||
442 | |||
443 | def _add_non_default_project(self): | ||
444 | """ Add another project """ | ||
445 | bbv = BitbakeVersion.objects.create(name="test bbv", giturl="/tmp/", | ||
446 | branch="master", dirpath="") | ||
447 | self.release = Release.objects.create(name="test release", | ||
448 | branch_name="master", | ||
449 | bitbake_version=bbv) | ||
450 | self.project = Project.objects.create_project(PROJECT_NAME, self.release) | ||
451 | self.project.is_default = False | ||
452 | self.project.save() | ||
453 | |||
454 | # fake the MACHINE variable | ||
455 | project_var = ProjectVariable.objects.create(project=self.project, | ||
456 | name='MACHINE', | ||
457 | value=self.MACHINE_NAME) | ||
458 | project_var.save() | ||
434 | 459 | ||
435 | def setUp(self): | 460 | def setUp(self): |
436 | """ Add default project manually """ | 461 | """ Add default project manually """ |
437 | project = Project.objects.create_project(self.PROJECT_NAME, None) | 462 | project = Project.objects.create_project(CLI_BUILDS_PROJECT_NAME, None) |
438 | self.default_project = project | 463 | self.default_project = project |
439 | self.default_project.is_default = True | 464 | self.default_project.is_default = True |
440 | self.default_project.save() | 465 | self.default_project.save() |
441 | 466 | ||
467 | # this project is only set for some of the tests | ||
468 | self.project = None | ||
469 | |||
442 | def test_default_project_hidden(self): | 470 | def test_default_project_hidden(self): |
443 | """ The default project should be hidden if it has no builds """ | 471 | """ The default project should be hidden if it has no builds """ |
444 | params = {"count": 10, "orderby": "updated:-", "page": 1} | 472 | params = {"count": 10, "orderby": "updated:-", "page": 1} |
@@ -446,25 +474,85 @@ class ProjectsPageTests(TestCase): | |||
446 | 474 | ||
447 | self.assertTrue(not('tr class="data"' in response.content), | 475 | self.assertTrue(not('tr class="data"' in response.content), |
448 | 'should be no project rows in the page') | 476 | 'should be no project rows in the page') |
449 | self.assertTrue(not(self.PROJECT_NAME in response.content), | 477 | self.assertTrue(not(CLI_BUILDS_PROJECT_NAME in response.content), |
450 | 'default project "cli builds" should not be in page') | 478 | 'default project "cli builds" should not be in page') |
451 | 479 | ||
452 | def test_default_project_has_build(self): | 480 | def test_default_project_has_build(self): |
453 | """ The default project should be shown if it has builds """ | 481 | """ The default project should be shown if it has builds """ |
454 | now = timezone.now() | 482 | self._add_build_to_default_project() |
455 | build = Build.objects.create(project=self.default_project, | ||
456 | started_on=now, | ||
457 | completed_on=now) | ||
458 | build.save() | ||
459 | 483 | ||
460 | params = {"count": 10, "orderby": "updated:-", "page": 1} | 484 | params = {"count": 10, "orderby": "updated:-", "page": 1} |
461 | response = self.client.get(reverse('all-projects'), params) | 485 | response = self.client.get(reverse('all-projects'), params) |
462 | 486 | ||
463 | self.assertTrue('tr class="data"' in response.content, | 487 | self.assertTrue('tr class="data"' in response.content, |
464 | 'should be a project row in the page') | 488 | 'should be a project row in the page') |
465 | self.assertTrue(self.PROJECT_NAME in response.content, | 489 | self.assertTrue(CLI_BUILDS_PROJECT_NAME in response.content, |
466 | 'default project "cli builds" should be in page') | 490 | 'default project "cli builds" should be in page') |
467 | 491 | ||
492 | def test_default_project_release(self): | ||
493 | """ | ||
494 | The release for the default project should display as | ||
495 | 'Not applicable' | ||
496 | """ | ||
497 | # need a build, otherwise project doesn't display at all | ||
498 | self._add_build_to_default_project() | ||
499 | |||
500 | # another project to test, which should show release | ||
501 | self._add_non_default_project() | ||
502 | |||
503 | response = self.client.get(reverse('all-projects'), follow=True) | ||
504 | soup = BeautifulSoup(response.content) | ||
505 | |||
506 | # check the release cell for the default project | ||
507 | attrs = {'data-project': str(self.default_project.id)} | ||
508 | rows = soup.find_all('tr', attrs=attrs) | ||
509 | self.assertEqual(len(rows), 1, 'should be one row for default project') | ||
510 | cells = rows[0].find_all('td', attrs={'data-project-field': 'release'}) | ||
511 | self.assertEqual(len(cells), 1, 'should be one release cell') | ||
512 | text = cells[0].select('span.muted')[0].text | ||
513 | self.assertEqual(text, 'Not applicable', | ||
514 | 'release should be not applicable for default project') | ||
515 | |||
516 | # check the link in the release cell for the other project | ||
517 | attrs = {'data-project': str(self.project.id)} | ||
518 | rows = soup.find_all('tr', attrs=attrs) | ||
519 | cells = rows[0].find_all('td', attrs={'data-project-field': 'release'}) | ||
520 | text = cells[0].select('a')[0].text | ||
521 | self.assertEqual(text, self.release.name, | ||
522 | 'release name should be shown for non-default project') | ||
523 | |||
524 | def test_default_project_machine(self): | ||
525 | """ | ||
526 | The machine for the default project should display as | ||
527 | 'Not applicable' | ||
528 | """ | ||
529 | # need a build, otherwise project doesn't display at all | ||
530 | self._add_build_to_default_project() | ||
531 | |||
532 | # another project to test, which should show machine | ||
533 | self._add_non_default_project() | ||
534 | |||
535 | response = self.client.get(reverse('all-projects'), follow=True) | ||
536 | soup = BeautifulSoup(response.content) | ||
537 | |||
538 | # check the machine cell for the default project | ||
539 | attrs = {'data-project': str(self.default_project.id)} | ||
540 | rows = soup.find_all('tr', attrs=attrs) | ||
541 | self.assertEqual(len(rows), 1, 'should be one row for default project') | ||
542 | cells = rows[0].find_all('td', attrs={'data-project-field': 'machine'}) | ||
543 | self.assertEqual(len(cells), 1, 'should be one machine cell') | ||
544 | text = cells[0].select('span.muted')[0].text | ||
545 | self.assertEqual(text, 'Not applicable', | ||
546 | 'machine should be not applicable for default project') | ||
547 | |||
548 | # check the link in the machine cell for the other project | ||
549 | attrs = {'data-project': str(self.project.id)} | ||
550 | rows = soup.find_all('tr', attrs=attrs) | ||
551 | cells = rows[0].find_all('td', attrs={'data-project-field': 'machine'}) | ||
552 | text = cells[0].select('a')[0].text | ||
553 | self.assertEqual(text, self.MACHINE_NAME, | ||
554 | 'machine name should be shown for non-default project') | ||
555 | |||
468 | class ProjectBuildsPageTests(TestCase): | 556 | class ProjectBuildsPageTests(TestCase): |
469 | """ Test data at /project/X/builds is displayed correctly """ | 557 | """ Test data at /project/X/builds is displayed correctly """ |
470 | 558 | ||