summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/tests.py')
-rw-r--r--bitbake/lib/toaster/toastergui/tests.py87
1 files changed, 0 insertions, 87 deletions
diff --git a/bitbake/lib/toaster/toastergui/tests.py b/bitbake/lib/toaster/toastergui/tests.py
index eebd1b79ba..a4cab58483 100644
--- a/bitbake/lib/toaster/toastergui/tests.py
+++ b/bitbake/lib/toaster/toastergui/tests.py
@@ -492,90 +492,3 @@ class ViewTests(TestCase):
492 page_two_data, 492 page_two_data,
493 "Changed page on table %s but first row is the " 493 "Changed page on table %s but first row is the "
494 "same as the previous page" % name) 494 "same as the previous page" % name)
495
496class BuildDashboardTests(TestCase):
497 """ Tests for the build dashboard /build/X """
498
499 def setUp(self):
500 bbv = BitbakeVersion.objects.create(name="bbv1", giturl="/tmp/",
501 branch="master", dirpath="")
502 release = Release.objects.create(name="release1",
503 bitbake_version=bbv)
504 project = Project.objects.create_project(name=PROJECT_NAME,
505 release=release)
506
507 now = timezone.now()
508
509 self.build1 = Build.objects.create(project=project,
510 started_on=now,
511 completed_on=now)
512
513 # exception
514 msg1 = 'an exception was thrown'
515 self.exception_message = LogMessage.objects.create(
516 build=self.build1,
517 level=LogMessage.EXCEPTION,
518 message=msg1
519 )
520
521 # critical
522 msg2 = 'a critical error occurred'
523 self.critical_message = LogMessage.objects.create(
524 build=self.build1,
525 level=LogMessage.CRITICAL,
526 message=msg2
527 )
528
529 def _get_build_dashboard_errors(self):
530 """
531 Get a list of HTML fragments representing the errors on the
532 build dashboard
533 """
534 url = reverse('builddashboard', args=(self.build1.id,))
535 response = self.client.get(url)
536 soup = BeautifulSoup(response.content)
537 return soup.select('#errors div.alert-error')
538
539 def _check_for_log_message(self, log_message):
540 """
541 Check whether the LogMessage instance <log_message> is
542 represented as an HTML error in the build dashboard page
543 """
544 errors = self._get_build_dashboard_errors()
545 self.assertEqual(len(errors), 2)
546
547 expected_text = log_message.message
548 expected_id = str(log_message.id)
549
550 found = False
551 for error in errors:
552 error_text = error.find('pre').text
553 text_matches = (error_text == expected_text)
554
555 error_id = error['data-error']
556 id_matches = (error_id == expected_id)
557
558 if text_matches and id_matches:
559 found = True
560 break
561
562 template_vars = (expected_text, error_text,
563 expected_id, error_id)
564 assertion_error_msg = 'exception not found as error: ' \
565 'expected text "%s" and got "%s"; ' \
566 'expected ID %s and got %s' % template_vars
567 self.assertTrue(found, assertion_error_msg)
568
569 def test_exceptions_show_as_errors(self):
570 """
571 LogMessages with level EXCEPTION should display in the errors
572 section of the page
573 """
574 self._check_for_log_message(self.exception_message)
575
576 def test_criticals_show_as_errors(self):
577 """
578 LogMessages with level CRITICAL should display in the errors
579 section of the page
580 """
581 self._check_for_log_message(self.critical_message)