[PATCH 4/4] toaster/test: Fixes functional tests warning on autobuilder
Alassane Yattara <[email protected]> Tue, 12 Dec 2023 15:16:43 +0100
| Newsgroups | org.yoctoproject.lists.toaster |
|---|---|
| Message-ID | <[email protected]> |
tests/functional/test_project_config.py::TestProjectConfig::test_set_down=
load_dir
/home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-p=
okysdk-linux/usr/lib/python3.11/unittest/case.py:678: DeprecationWarning:=
It is deprecated to return a value that is not None from a test case (<b=
ound method TestProjectConfig.test_set_download_dir of <toaster.tests.fun=
ctional.test_project_config.TestProjectConfig testMethod=3Dtest_set_downl=
oad_dir>>)
return self.run(*args, **kwds)
tests/functional/test_project_config.py::TestProjectConfig::test_set_ssta=
te_dir
/home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-p=
okysdk-linux/usr/lib/python3.11/unittest/case.py:678: DeprecationWarning:=
It is deprecated to return a value that is not None from a test case (<b=
ound method TestProjectConfig.test_set_sstate_dir of <toaster.tests.funct=
ional.test_project_config.TestProjectConfig testMethod=3Dtest_set_sstate_=
dir>>)
return self.run(*args, **kwds)
Signed-off-by: Alassane Yattara <[email protected]>
---
.../tests/functional/test_project_config.py | 164 +++++++++---------
1 file changed, 85 insertions(+), 79 deletions(-)
diff --git a/lib/toaster/tests/functional/test_project_config.py b/lib/to=
aster/tests/functional/test_project_config.py
index 2d162d81..dbee36aa 100644
--- a/lib/toaster/tests/functional/test_project_config.py
+++ b/lib/toaster/tests/functional/test_project_config.py
@@ -163,51 +163,53 @@ class TestProjectConfig(SeleniumFunctionalTestCase)=
:
change_dl_dir_btn =3D self.wait_until_visible('#change-dl_di=
r-icon', poll=3D2)
except TimeoutException:
# If download dir is not displayed, test is skipped
- return True
- change_dl_dir_btn =3D self.wait_until_visible('#change-dl_dir-ic=
on', poll=3D2)
- change_dl_dir_btn.click()
+ change_dl_dir_btn =3D None
=20
- # downloads dir path doesn't start with / or ${...}
- input_field =3D self.wait_until_visible('#new-dl_dir', poll=3D2)
- input_field.clear()
- self.enter_text('#new-dl_dir', 'home/foo')
- element =3D self.wait_until_visible('#hintError-initialChar-dl_d=
ir', poll=3D2)
+ if change_dl_dir_btn:
+ change_dl_dir_btn =3D self.wait_until_visible('#change-dl_di=
r-icon', poll=3D2)
+ change_dl_dir_btn.click()
+
+ # downloads dir path doesn't start with / or ${...}
+ input_field =3D self.wait_until_visible('#new-dl_dir', poll=3D=
2)
+ input_field.clear()
+ self.enter_text('#new-dl_dir', 'home/foo')
+ element =3D self.wait_until_visible('#hintError-initialChar-=
dl_dir', poll=3D2)
=20
- msg =3D 'downloads directory path starts with invalid character =
but ' \
- 'treated as valid'
- self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), =
msg)
+ msg =3D 'downloads directory path starts with invalid charac=
ter but ' \
+ 'treated as valid'
+ self.assertTrue((self.INVALID_PATH_START_TEXT in element.tex=
t), msg)
=20
- # downloads dir path has a space
- self.driver.find_element(By.ID, 'new-dl_dir').clear()
- self.enter_text('#new-dl_dir', '/foo/bar a')
+ # downloads dir path has a space
+ self.driver.find_element(By.ID, 'new-dl_dir').clear()
+ self.enter_text('#new-dl_dir', '/foo/bar a')
=20
- element =3D self.wait_until_visible('#hintError-dl_dir', poll=3D=
2)
- msg =3D 'downloads directory path characters invalid but treated=
as valid'
- self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), m=
sg)
+ element =3D self.wait_until_visible('#hintError-dl_dir', pol=
l=3D2)
+ msg =3D 'downloads directory path characters invalid but tre=
ated as valid'
+ self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text=
), msg)
=20
- # downloads dir path starts with ${...} but has a space
- self.driver.find_element(By.ID,'new-dl_dir').clear()
- self.enter_text('#new-dl_dir', '${TOPDIR}/down foo')
+ # downloads dir path starts with ${...} but has a space
+ self.driver.find_element(By.ID,'new-dl_dir').clear()
+ self.enter_text('#new-dl_dir', '${TOPDIR}/down foo')
=20
- element =3D self.wait_until_visible('#hintError-dl_dir', poll=3D=
2)
- msg =3D 'downloads directory path characters invalid but treated=
as valid'
- self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), m=
sg)
+ element =3D self.wait_until_visible('#hintError-dl_dir', pol=
l=3D2)
+ msg =3D 'downloads directory path characters invalid but tre=
ated as valid'
+ self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text=
), msg)
=20
- # downloads dir path starts with /
- self.driver.find_element(By.ID,'new-dl_dir').clear()
- self.enter_text('#new-dl_dir', '/bar/foo')
+ # downloads dir path starts with /
+ self.driver.find_element(By.ID,'new-dl_dir').clear()
+ self.enter_text('#new-dl_dir', '/bar/foo')
=20
- hidden_element =3D self.driver.find_element(By.ID,'hintError-dl_=
dir')
- self.assertEqual(hidden_element.is_displayed(), False,
- 'downloads directory path valid but treated as invalid')
+ hidden_element =3D self.driver.find_element(By.ID,'hintError=
-dl_dir')
+ self.assertEqual(hidden_element.is_displayed(), False,
+ 'downloads directory path valid but treated as invalid')
=20
- # downloads dir path starts with ${...}
- self.driver.find_element(By.ID,'new-dl_dir').clear()
- self.enter_text('#new-dl_dir', '${TOPDIR}/down')
+ # downloads dir path starts with ${...}
+ self.driver.find_element(By.ID,'new-dl_dir').clear()
+ self.enter_text('#new-dl_dir', '${TOPDIR}/down')
=20
- hidden_element =3D self.driver.find_element(By.ID,'hintError-dl_=
dir')
- self.assertEqual(hidden_element.is_displayed(), False,
- 'downloads directory path valid but treated as invalid')
+ hidden_element =3D self.driver.find_element(By.ID,'hintError=
-dl_dir')
+ self.assertEqual(hidden_element.is_displayed(), False,
+ 'downloads directory path valid but treated as invalid')
=20
def test_set_sstate_dir(self):
"""
@@ -217,53 +219,57 @@ class TestProjectConfig(SeleniumFunctionalTestCase)=
:
self._navigate_bbv_page()
=20
try:
- self.wait_until_visible('#change-sstate_dir-icon', poll=3D2)
+ btn_chg_sstate_dir =3D self.wait_until_visible(
+ '#change-sstate_dir-icon',
+ poll=3D2
+ )
self.click('#change-sstate_dir-icon')
except TimeoutException:
# If sstate_dir is not displayed, test is skipped
- return True
-
- # path doesn't start with / or ${...}
- input_field =3D self.wait_until_visible('#new-sstate_dir', poll=3D=
2)
- input_field.clear()
- self.enter_text('#new-sstate_dir', 'home/foo')
- element =3D self.wait_until_visible('#hintError-initialChar-ssta=
te_dir', poll=3D2)
-
- msg =3D 'sstate directory path starts with invalid character but=
' \
- 'treated as valid'
- self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), =
msg)
-
- # path has a space
- self.driver.find_element(By.ID, 'new-sstate_dir').clear()
- self.enter_text('#new-sstate_dir', '/foo/bar a')
-
- element =3D self.wait_until_visible('#hintError-sstate_dir', pol=
l=3D2)
- msg =3D 'sstate directory path characters invalid but treated as=
valid'
- self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), m=
sg)
-
- # path starts with ${...} but has a space
- self.driver.find_element(By.ID,'new-sstate_dir').clear()
- self.enter_text('#new-sstate_dir', '${TOPDIR}/down foo')
-
- element =3D self.wait_until_visible('#hintError-sstate_dir', pol=
l=3D2)
- msg =3D 'sstate directory path characters invalid but treated as=
valid'
- self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), m=
sg)
-
- # path starts with /
- self.driver.find_element(By.ID,'new-sstate_dir').clear()
- self.enter_text('#new-sstate_dir', '/bar/foo')
-
- hidden_element =3D self.driver.find_element(By.ID, 'hintError-ss=
tate_dir')
- self.assertEqual(hidden_element.is_displayed(), False,
- 'sstate directory path valid but treated as invalid')
-
- # paths starts with ${...}
- self.driver.find_element(By.ID, 'new-sstate_dir').clear()
- self.enter_text('#new-sstate_dir', '${TOPDIR}/down')
-
- hidden_element =3D self.driver.find_element(By.ID, 'hintError-ss=
tate_dir')
- self.assertEqual(hidden_element.is_displayed(), False,
- 'sstate directory path valid but treated as invalid')
+ btn_chg_sstate_dir =3D None
+
+ if btn_chg_sstate_dir: # Skip continuation if sstate_dir is not=
displayed
+ # path doesn't start with / or ${...}
+ input_field =3D self.wait_until_visible('#new-sstate_dir', p=
oll=3D2)
+ input_field.clear()
+ self.enter_text('#new-sstate_dir', 'home/foo')
+ element =3D self.wait_until_visible('#hintError-initialChar-=
sstate_dir', poll=3D2)
+
+ msg =3D 'sstate directory path starts with invalid character=
but ' \
+ 'treated as valid'
+ self.assertTrue((self.INVALID_PATH_START_TEXT in element.tex=
t), msg)
+
+ # path has a space
+ self.driver.find_element(By.ID, 'new-sstate_dir').clear()
+ self.enter_text('#new-sstate_dir', '/foo/bar a')
+
+ element =3D self.wait_until_visible('#hintError-sstate_dir',=
poll=3D2)
+ msg =3D 'sstate directory path characters invalid but treate=
d as valid'
+ self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text=
), msg)
+
+ # path starts with ${...} but has a space
+ self.driver.find_element(By.ID,'new-sstate_dir').clear()
+ self.enter_text('#new-sstate_dir', '${TOPDIR}/down foo')
+
+ element =3D self.wait_until_visible('#hintError-sstate_dir',=
poll=3D2)
+ msg =3D 'sstate directory path characters invalid but treate=
d as valid'
+ self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text=
), msg)
+
+ # path starts with /
+ self.driver.find_element(By.ID,'new-sstate_dir').clear()
+ self.enter_text('#new-sstate_dir', '/bar/foo')
+
+ hidden_element =3D self.driver.find_element(By.ID, 'hintErro=
r-sstate_dir')
+ self.assertEqual(hidden_element.is_displayed(), False,
+ 'sstate directory path valid but treated as invalid')
+
+ # paths starts with ${...}
+ self.driver.find_element(By.ID, 'new-sstate_dir').clear()
+ self.enter_text('#new-sstate_dir', '${TOPDIR}/down')
+
+ hidden_element =3D self.driver.find_element(By.ID, 'hintErro=
r-sstate_dir')
+ self.assertEqual(hidden_element.is_displayed(), False,
+ 'sstate directory path valid but treated as invalid')
=20
def _change_bbv_value(self, **kwargs):
var_name, field, btn_id, input_id, value, save_btn, *_ =3D kwarg=
s.values()
--=20
2.34.1