mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 13:29:49 +00:00
bitbake: toaster-tests: tests for build dashboard
Convert existing tests to Selenium. Add basic tests to check that the modal contains radio buttons to select a custom image to edit when a build built multiple custom images, and to create a new custom image from one of the images built during the build. [YOCTO #9123] (Bitbake rev: c07f65feaba50b13a38635bd8149804c823d446a) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
1cf8f215b3
commit
d9dd864c68
@@ -492,90 +492,3 @@ class ViewTests(TestCase):
|
||||
page_two_data,
|
||||
"Changed page on table %s but first row is the "
|
||||
"same as the previous page" % name)
|
||||
|
||||
class BuildDashboardTests(TestCase):
|
||||
""" Tests for the build dashboard /build/X """
|
||||
|
||||
def setUp(self):
|
||||
bbv = BitbakeVersion.objects.create(name="bbv1", giturl="/tmp/",
|
||||
branch="master", dirpath="")
|
||||
release = Release.objects.create(name="release1",
|
||||
bitbake_version=bbv)
|
||||
project = Project.objects.create_project(name=PROJECT_NAME,
|
||||
release=release)
|
||||
|
||||
now = timezone.now()
|
||||
|
||||
self.build1 = Build.objects.create(project=project,
|
||||
started_on=now,
|
||||
completed_on=now)
|
||||
|
||||
# exception
|
||||
msg1 = 'an exception was thrown'
|
||||
self.exception_message = LogMessage.objects.create(
|
||||
build=self.build1,
|
||||
level=LogMessage.EXCEPTION,
|
||||
message=msg1
|
||||
)
|
||||
|
||||
# critical
|
||||
msg2 = 'a critical error occurred'
|
||||
self.critical_message = LogMessage.objects.create(
|
||||
build=self.build1,
|
||||
level=LogMessage.CRITICAL,
|
||||
message=msg2
|
||||
)
|
||||
|
||||
def _get_build_dashboard_errors(self):
|
||||
"""
|
||||
Get a list of HTML fragments representing the errors on the
|
||||
build dashboard
|
||||
"""
|
||||
url = reverse('builddashboard', args=(self.build1.id,))
|
||||
response = self.client.get(url)
|
||||
soup = BeautifulSoup(response.content)
|
||||
return soup.select('#errors div.alert-error')
|
||||
|
||||
def _check_for_log_message(self, log_message):
|
||||
"""
|
||||
Check whether the LogMessage instance <log_message> is
|
||||
represented as an HTML error in the build dashboard page
|
||||
"""
|
||||
errors = self._get_build_dashboard_errors()
|
||||
self.assertEqual(len(errors), 2)
|
||||
|
||||
expected_text = log_message.message
|
||||
expected_id = str(log_message.id)
|
||||
|
||||
found = False
|
||||
for error in errors:
|
||||
error_text = error.find('pre').text
|
||||
text_matches = (error_text == expected_text)
|
||||
|
||||
error_id = error['data-error']
|
||||
id_matches = (error_id == expected_id)
|
||||
|
||||
if text_matches and id_matches:
|
||||
found = True
|
||||
break
|
||||
|
||||
template_vars = (expected_text, error_text,
|
||||
expected_id, error_id)
|
||||
assertion_error_msg = 'exception not found as error: ' \
|
||||
'expected text "%s" and got "%s"; ' \
|
||||
'expected ID %s and got %s' % template_vars
|
||||
self.assertTrue(found, assertion_error_msg)
|
||||
|
||||
def test_exceptions_show_as_errors(self):
|
||||
"""
|
||||
LogMessages with level EXCEPTION should display in the errors
|
||||
section of the page
|
||||
"""
|
||||
self._check_for_log_message(self.exception_message)
|
||||
|
||||
def test_criticals_show_as_errors(self):
|
||||
"""
|
||||
LogMessages with level CRITICAL should display in the errors
|
||||
section of the page
|
||||
"""
|
||||
self._check_for_log_message(self.critical_message)
|
||||
|
||||
Reference in New Issue
Block a user