mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00

Added 7 new testcases that verify the UI interface and elements of the project detail page. This testcases can be found on testopia in the links: Verifies that the project is created and that you get redirected to the configuration page https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1514 Verifies that the left side bar menu, all links are clickable and they show on the UI https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1515 Verifies that after creating a project the default project configuration is created https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1516 Verifies that the default machine is set, once creating the project https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1517 Verifies the built recipes information of the project detail page https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1518 Verifies the default release information of the project https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1519 Verifies that the default layers are assigned to the project https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1520 Verifies that the links to the Configuration, Builds, Import layer and New Custom Image are present and work. [YOCTO #9808] (Bitbake rev: eaeddaf96efb8079b307652eac208f4ab5019ad4) Signed-off-by: Libertad Cruz <libertad.cruz@intel.com> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: David Reyna <David.Reyna@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
123 lines
4.3 KiB
Python
123 lines
4.3 KiB
Python
#! /usr/bin/env python
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
#
|
|
# BitBake Toaster functional tests implementation
|
|
#
|
|
# Copyright (C) 2017 Intel Corporation
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
# published by the Free Software Foundation.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
import os
|
|
import logging
|
|
import subprocess
|
|
import signal
|
|
import time
|
|
import re
|
|
|
|
from tests.browser.selenium_helpers_base import SeleniumTestCaseBase
|
|
from tests.builds.buildtest import load_build_environment
|
|
|
|
logger = logging.getLogger("toaster")
|
|
|
|
class SeleniumFunctionalTestCase(SeleniumTestCaseBase):
|
|
wait_toaster_time = 5
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
# So that the buildinfo helper uses the test database'
|
|
if os.environ.get('DJANGO_SETTINGS_MODULE', '') != \
|
|
'toastermain.settings_test':
|
|
raise RuntimeError("Please initialise django with the tests settings: " \
|
|
"DJANGO_SETTINGS_MODULE='toastermain.settings_test'")
|
|
|
|
load_build_environment()
|
|
|
|
# start toaster
|
|
cmd = "bash -c 'source toaster start'"
|
|
p = subprocess.Popen(
|
|
cmd,
|
|
cwd=os.environ.get("BUILDDIR"),
|
|
shell=True)
|
|
if p.wait() != 0:
|
|
raise RuntimeError("Can't initialize toaster")
|
|
|
|
super(SeleniumFunctionalTestCase, cls).setUpClass()
|
|
cls.live_server_url = 'http://localhost:8000/'
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
super(SeleniumFunctionalTestCase, cls).tearDownClass()
|
|
|
|
# XXX: source toaster stop gets blocked, to review why?
|
|
# from now send SIGTERM by hand
|
|
time.sleep(cls.wait_toaster_time)
|
|
builddir = os.environ.get("BUILDDIR")
|
|
|
|
with open(os.path.join(builddir, '.toastermain.pid'), 'r') as f:
|
|
toastermain_pid = int(f.read())
|
|
os.kill(toastermain_pid, signal.SIGTERM)
|
|
with open(os.path.join(builddir, '.runbuilds.pid'), 'r') as f:
|
|
runbuilds_pid = int(f.read())
|
|
os.kill(runbuilds_pid, signal.SIGTERM)
|
|
|
|
|
|
def get_URL(self):
|
|
rc=self.get_page_source()
|
|
project_url=re.search("(projectPageUrl\s:\s\")(.*)(\",)",rc)
|
|
return project_url.group(2)
|
|
|
|
|
|
def find_element_by_link_text_in_table(self, table_id, link_text):
|
|
"""
|
|
Assume there're multiple suitable "find_element_by_link_text".
|
|
In this circumstance we need to specify "table".
|
|
"""
|
|
try:
|
|
table_element = self.get_table_element(table_id)
|
|
element = table_element.find_element_by_link_text(link_text)
|
|
except NoSuchElementException as e:
|
|
print('no element found')
|
|
raise
|
|
return element
|
|
|
|
def get_table_element(self, table_id, *coordinate):
|
|
if len(coordinate) == 0:
|
|
#return whole-table element
|
|
element_xpath = "//*[@id='" + table_id + "']"
|
|
try:
|
|
element = self.driver.find_element_by_xpath(element_xpath)
|
|
except NoSuchElementException as e:
|
|
raise
|
|
return element
|
|
row = coordinate[0]
|
|
|
|
if len(coordinate) == 1:
|
|
#return whole-row element
|
|
element_xpath = "//*[@id='" + table_id + "']/tbody/tr[" + str(row) + "]"
|
|
try:
|
|
element = self.driver.find_element_by_xpath(element_xpath)
|
|
except NoSuchElementException as e:
|
|
return False
|
|
return element
|
|
#now we are looking for an element with specified X and Y
|
|
column = coordinate[1]
|
|
|
|
element_xpath = "//*[@id='" + table_id + "']/tbody/tr[" + str(row) + "]/td[" + str(column) + "]"
|
|
try:
|
|
element = self.driver.find_element_by_xpath(element_xpath)
|
|
except NoSuchElementException as e:
|
|
return False
|
|
return element
|