Message ID | 20231212141708.19395-4-alassane.yattara@savoirfairelinux.com |
---|---|
State | New |
Headers | show |
Series | [1/4] toaster/test: bug-fix element click intercepted in browser/test_layerdetails_page.py | expand |
On Tue, 2023-12-12 at 15:17 +0100, Alassane Yattara wrote: > tests/functional/test_project_config.py::TestProjectConfig::test_set_download_dir > /home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-pokysdk-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 (<bound method TestProjectConfig.test_set_download_dir of <toaster.tests.functional.test_project_config.TestProjectConfig testMethod=test_set_download_dir>>) > return self.run(*args, **kwds) > > tests/functional/test_project_config.py::TestProjectConfig::test_set_sstate_dir > /home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-pokysdk-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 (<bound method TestProjectConfig.test_set_sstate_dir of <toaster.tests.functional.test_project_config.TestProjectConfig testMethod=test_set_sstate_dir>>) > return self.run(*args, **kwds) > > Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com> > --- > .../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/toaster/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 = self.wait_until_visible('#change-dl_dir-icon', poll=2) > except TimeoutException: > # If download dir is not displayed, test is skipped > - return True > - change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2) > - change_dl_dir_btn.click() > + change_dl_dir_btn = None > > - # downloads dir path doesn't start with / or ${...} > - input_field = self.wait_until_visible('#new-dl_dir', poll=2) > - input_field.clear() > - self.enter_text('#new-dl_dir', 'home/foo') > - element = self.wait_until_visible('#hintError-initialChar-dl_dir', poll=2) > + if change_dl_dir_btn: > + change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2) > + change_dl_dir_btn.click() > + > + # downloads dir path doesn't start with / or ${...} > + input_field = self.wait_until_visible('#new-dl_dir', poll=2) > + input_field.clear() > + self.enter_text('#new-dl_dir', 'home/foo') > + element = self.wait_until_visible('#hintError-initialChar-dl_dir', poll=2) > > - msg = 'downloads directory path starts with invalid character but ' \ > - 'treated as valid' > - self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) > + msg = 'downloads directory path starts with invalid character but ' \ > + 'treated as valid' > + self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) > > - # 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') > > - element = self.wait_until_visible('#hintError-dl_dir', poll=2) > - msg = 'downloads directory path characters invalid but treated as valid' > - self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > + element = self.wait_until_visible('#hintError-dl_dir', poll=2) > + msg = 'downloads directory path characters invalid but treated as valid' > + self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > > - # 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') > > - element = self.wait_until_visible('#hintError-dl_dir', poll=2) > - msg = 'downloads directory path characters invalid but treated as valid' > - self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > + element = self.wait_until_visible('#hintError-dl_dir', poll=2) > + msg = 'downloads directory path characters invalid but treated as valid' > + self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > > - # 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') > > - hidden_element = 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 = self.driver.find_element(By.ID,'hintError-dl_dir') > + self.assertEqual(hidden_element.is_displayed(), False, > + 'downloads directory path valid but treated as invalid') > > - # 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') > > - hidden_element = 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 = self.driver.find_element(By.ID,'hintError-dl_dir') > + self.assertEqual(hidden_element.is_displayed(), False, > + 'downloads directory path valid but treated as invalid') > > def test_set_sstate_dir(self): > """ > @@ -217,53 +219,57 @@ class TestProjectConfig(SeleniumFunctionalTestCase): > self._navigate_bbv_page() > > try: > - self.wait_until_visible('#change-sstate_dir-icon', poll=2) > + btn_chg_sstate_dir = self.wait_until_visible( > + '#change-sstate_dir-icon', > + poll=2 > + ) > self.click('#change-sstate_dir-icon') > except TimeoutException: > # If sstate_dir is not displayed, test is skipped > - return True > - Wouldn't it be easier to do something like a self.skipTest("Some reason") here? That would mean the rest of the code didn't need to change? Cheers, Richard
Richard, Yes, you're right skiptest is another way, in fact I preferred this method in a testcase, but to avoid 2 or more skipping inside tests, I chose if condition. Alassane ----- Mail original ----- De: "Richard Purdie" <richard.purdie@linuxfoundation.org> À: "Alassane Yattara" <alassane.yattara@savoirfairelinux.com>, "bitbake-devel" <bitbake-devel@lists.openembedded.org> Envoyé: Mercredi 13 Décembre 2023 14:58:24 Objet: Re: [bitbake-devel] [PATCH 4/4] toaster/test: Fixes functional tests warning on autobuilder On Tue, 2023-12-12 at 15:17 +0100, Alassane Yattara wrote: > tests/functional/test_project_config.py::TestProjectConfig::test_set_download_dir > /home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-pokysdk-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 (<bound method TestProjectConfig.test_set_download_dir of <toaster.tests.functional.test_project_config.TestProjectConfig testMethod=test_set_download_dir>>) > return self.run(*args, **kwds) > > tests/functional/test_project_config.py::TestProjectConfig::test_set_sstate_dir > /home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-pokysdk-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 (<bound method TestProjectConfig.test_set_sstate_dir of <toaster.tests.functional.test_project_config.TestProjectConfig testMethod=test_set_sstate_dir>>) > return self.run(*args, **kwds) > > Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com> > --- > .../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/toaster/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 = self.wait_until_visible('#change-dl_dir-icon', poll=2) > except TimeoutException: > # If download dir is not displayed, test is skipped > - return True > - change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2) > - change_dl_dir_btn.click() > + change_dl_dir_btn = None > > - # downloads dir path doesn't start with / or ${...} > - input_field = self.wait_until_visible('#new-dl_dir', poll=2) > - input_field.clear() > - self.enter_text('#new-dl_dir', 'home/foo') > - element = self.wait_until_visible('#hintError-initialChar-dl_dir', poll=2) > + if change_dl_dir_btn: > + change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2) > + change_dl_dir_btn.click() > + > + # downloads dir path doesn't start with / or ${...} > + input_field = self.wait_until_visible('#new-dl_dir', poll=2) > + input_field.clear() > + self.enter_text('#new-dl_dir', 'home/foo') > + element = self.wait_until_visible('#hintError-initialChar-dl_dir', poll=2) > > - msg = 'downloads directory path starts with invalid character but ' \ > - 'treated as valid' > - self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) > + msg = 'downloads directory path starts with invalid character but ' \ > + 'treated as valid' > + self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) > > - # 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') > > - element = self.wait_until_visible('#hintError-dl_dir', poll=2) > - msg = 'downloads directory path characters invalid but treated as valid' > - self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > + element = self.wait_until_visible('#hintError-dl_dir', poll=2) > + msg = 'downloads directory path characters invalid but treated as valid' > + self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > > - # 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') > > - element = self.wait_until_visible('#hintError-dl_dir', poll=2) > - msg = 'downloads directory path characters invalid but treated as valid' > - self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > + element = self.wait_until_visible('#hintError-dl_dir', poll=2) > + msg = 'downloads directory path characters invalid but treated as valid' > + self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > > - # 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') > > - hidden_element = 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 = self.driver.find_element(By.ID,'hintError-dl_dir') > + self.assertEqual(hidden_element.is_displayed(), False, > + 'downloads directory path valid but treated as invalid') > > - # 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') > > - hidden_element = 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 = self.driver.find_element(By.ID,'hintError-dl_dir') > + self.assertEqual(hidden_element.is_displayed(), False, > + 'downloads directory path valid but treated as invalid') > > def test_set_sstate_dir(self): > """ > @@ -217,53 +219,57 @@ class TestProjectConfig(SeleniumFunctionalTestCase): > self._navigate_bbv_page() > > try: > - self.wait_until_visible('#change-sstate_dir-icon', poll=2) > + btn_chg_sstate_dir = self.wait_until_visible( > + '#change-sstate_dir-icon', > + poll=2 > + ) > self.click('#change-sstate_dir-icon') > except TimeoutException: > # If sstate_dir is not displayed, test is skipped > - return True > - Wouldn't it be easier to do something like a self.skipTest("Some reason") here? That would mean the rest of the code didn't need to change? Cheers, Richard -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#15660): https://lists.openembedded.org/g/bitbake-devel/message/15660 Mute This Topic: https://lists.openembedded.org/mt/103130087/7896845 Group Owner: bitbake-devel+owner@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/leave/12674735/7896845/557127541/xyzzy [alassane.yattara@savoirfairelinux.com] -=-=-=-=-=-=-=-=-=-=-=-
Richard, Also, I am currently working on a new version of this series of patches with new bug-fixes on functional tests. Alassane ----- Mail original ----- De: "Richard Purdie" <richard.purdie@linuxfoundation.org> À: "Alassane Yattara" <alassane.yattara@savoirfairelinux.com>, "bitbake-devel" <bitbake-devel@lists.openembedded.org> Envoyé: Mercredi 13 Décembre 2023 14:58:24 Objet: Re: [bitbake-devel] [PATCH 4/4] toaster/test: Fixes functional tests warning on autobuilder On Tue, 2023-12-12 at 15:17 +0100, Alassane Yattara wrote: > tests/functional/test_project_config.py::TestProjectConfig::test_set_download_dir > /home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-pokysdk-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 (<bound method TestProjectConfig.test_set_download_dir of <toaster.tests.functional.test_project_config.TestProjectConfig testMethod=test_set_download_dir>>) > return self.run(*args, **kwds) > > tests/functional/test_project_config.py::TestProjectConfig::test_set_sstate_dir > /home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-pokysdk-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 (<bound method TestProjectConfig.test_set_sstate_dir of <toaster.tests.functional.test_project_config.TestProjectConfig testMethod=test_set_sstate_dir>>) > return self.run(*args, **kwds) > > Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com> > --- > .../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/toaster/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 = self.wait_until_visible('#change-dl_dir-icon', poll=2) > except TimeoutException: > # If download dir is not displayed, test is skipped > - return True > - change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2) > - change_dl_dir_btn.click() > + change_dl_dir_btn = None > > - # downloads dir path doesn't start with / or ${...} > - input_field = self.wait_until_visible('#new-dl_dir', poll=2) > - input_field.clear() > - self.enter_text('#new-dl_dir', 'home/foo') > - element = self.wait_until_visible('#hintError-initialChar-dl_dir', poll=2) > + if change_dl_dir_btn: > + change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2) > + change_dl_dir_btn.click() > + > + # downloads dir path doesn't start with / or ${...} > + input_field = self.wait_until_visible('#new-dl_dir', poll=2) > + input_field.clear() > + self.enter_text('#new-dl_dir', 'home/foo') > + element = self.wait_until_visible('#hintError-initialChar-dl_dir', poll=2) > > - msg = 'downloads directory path starts with invalid character but ' \ > - 'treated as valid' > - self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) > + msg = 'downloads directory path starts with invalid character but ' \ > + 'treated as valid' > + self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) > > - # 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') > > - element = self.wait_until_visible('#hintError-dl_dir', poll=2) > - msg = 'downloads directory path characters invalid but treated as valid' > - self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > + element = self.wait_until_visible('#hintError-dl_dir', poll=2) > + msg = 'downloads directory path characters invalid but treated as valid' > + self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > > - # 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') > > - element = self.wait_until_visible('#hintError-dl_dir', poll=2) > - msg = 'downloads directory path characters invalid but treated as valid' > - self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > + element = self.wait_until_visible('#hintError-dl_dir', poll=2) > + msg = 'downloads directory path characters invalid but treated as valid' > + self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) > > - # 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') > > - hidden_element = 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 = self.driver.find_element(By.ID,'hintError-dl_dir') > + self.assertEqual(hidden_element.is_displayed(), False, > + 'downloads directory path valid but treated as invalid') > > - # 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') > > - hidden_element = 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 = self.driver.find_element(By.ID,'hintError-dl_dir') > + self.assertEqual(hidden_element.is_displayed(), False, > + 'downloads directory path valid but treated as invalid') > > def test_set_sstate_dir(self): > """ > @@ -217,53 +219,57 @@ class TestProjectConfig(SeleniumFunctionalTestCase): > self._navigate_bbv_page() > > try: > - self.wait_until_visible('#change-sstate_dir-icon', poll=2) > + btn_chg_sstate_dir = self.wait_until_visible( > + '#change-sstate_dir-icon', > + poll=2 > + ) > self.click('#change-sstate_dir-icon') > except TimeoutException: > # If sstate_dir is not displayed, test is skipped > - return True > - Wouldn't it be easier to do something like a self.skipTest("Some reason") here? That would mean the rest of the code didn't need to change? Cheers, Richard
diff --git a/lib/toaster/tests/functional/test_project_config.py b/lib/toaster/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 = self.wait_until_visible('#change-dl_dir-icon', poll=2) except TimeoutException: # If download dir is not displayed, test is skipped - return True - change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2) - change_dl_dir_btn.click() + change_dl_dir_btn = None - # downloads dir path doesn't start with / or ${...} - input_field = self.wait_until_visible('#new-dl_dir', poll=2) - input_field.clear() - self.enter_text('#new-dl_dir', 'home/foo') - element = self.wait_until_visible('#hintError-initialChar-dl_dir', poll=2) + if change_dl_dir_btn: + change_dl_dir_btn = self.wait_until_visible('#change-dl_dir-icon', poll=2) + change_dl_dir_btn.click() + + # downloads dir path doesn't start with / or ${...} + input_field = self.wait_until_visible('#new-dl_dir', poll=2) + input_field.clear() + self.enter_text('#new-dl_dir', 'home/foo') + element = self.wait_until_visible('#hintError-initialChar-dl_dir', poll=2) - msg = 'downloads directory path starts with invalid character but ' \ - 'treated as valid' - self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) + msg = 'downloads directory path starts with invalid character but ' \ + 'treated as valid' + self.assertTrue((self.INVALID_PATH_START_TEXT in element.text), msg) - # 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') - element = self.wait_until_visible('#hintError-dl_dir', poll=2) - msg = 'downloads directory path characters invalid but treated as valid' - self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) + element = self.wait_until_visible('#hintError-dl_dir', poll=2) + msg = 'downloads directory path characters invalid but treated as valid' + self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) - # 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') - element = self.wait_until_visible('#hintError-dl_dir', poll=2) - msg = 'downloads directory path characters invalid but treated as valid' - self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) + element = self.wait_until_visible('#hintError-dl_dir', poll=2) + msg = 'downloads directory path characters invalid but treated as valid' + self.assertTrue((self.INVALID_PATH_CHAR_TEXT in element.text), msg) - # 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') - hidden_element = 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 = self.driver.find_element(By.ID,'hintError-dl_dir') + self.assertEqual(hidden_element.is_displayed(), False, + 'downloads directory path valid but treated as invalid') - # 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') - hidden_element = 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 = self.driver.find_element(By.ID,'hintError-dl_dir') + self.assertEqual(hidden_element.is_displayed(), False, + 'downloads directory path valid but treated as invalid') def test_set_sstate_dir(self): """ @@ -217,53 +219,57 @@ class TestProjectConfig(SeleniumFunctionalTestCase): self._navigate_bbv_page() try: - self.wait_until_visible('#change-sstate_dir-icon', poll=2) + btn_chg_sstate_dir = self.wait_until_visible( + '#change-sstate_dir-icon', + poll=2 + ) 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 = self.wait_until_visible('#new-sstate_dir', poll=2) - input_field.clear() - self.enter_text('#new-sstate_dir', 'home/foo') - element = self.wait_until_visible('#hintError-initialChar-sstate_dir', poll=2) - - msg = '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 = self.wait_until_visible('#hintError-sstate_dir', poll=2) - msg = 'sstate directory path characters invalid but treated 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 = self.wait_until_visible('#hintError-sstate_dir', poll=2) - msg = 'sstate directory path characters invalid but treated 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 = self.driver.find_element(By.ID, 'hintError-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 = self.driver.find_element(By.ID, 'hintError-sstate_dir') - self.assertEqual(hidden_element.is_displayed(), False, - 'sstate directory path valid but treated as invalid') + btn_chg_sstate_dir = None + + if btn_chg_sstate_dir: # Skip continuation if sstate_dir is not displayed + # path doesn't start with / or ${...} + input_field = self.wait_until_visible('#new-sstate_dir', poll=2) + input_field.clear() + self.enter_text('#new-sstate_dir', 'home/foo') + element = self.wait_until_visible('#hintError-initialChar-sstate_dir', poll=2) + + msg = '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 = self.wait_until_visible('#hintError-sstate_dir', poll=2) + msg = 'sstate directory path characters invalid but treated 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 = self.wait_until_visible('#hintError-sstate_dir', poll=2) + msg = 'sstate directory path characters invalid but treated 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 = self.driver.find_element(By.ID, 'hintError-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 = self.driver.find_element(By.ID, 'hintError-sstate_dir') + self.assertEqual(hidden_element.is_displayed(), False, + 'sstate directory path valid but treated as invalid') def _change_bbv_value(self, **kwargs): var_name, field, btn_id, input_id, value, save_btn, *_ = kwargs.values()
tests/functional/test_project_config.py::TestProjectConfig::test_set_download_dir /home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-pokysdk-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 (<bound method TestProjectConfig.test_set_download_dir of <toaster.tests.functional.test_project_config.TestProjectConfig testMethod=test_set_download_dir>>) return self.run(*args, **kwds) tests/functional/test_project_config.py::TestProjectConfig::test_set_sstate_dir /home/pokybuild/yocto-worker/toaster/build/buildtools/sysroots/x86_64-pokysdk-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 (<bound method TestProjectConfig.test_set_sstate_dir of <toaster.tests.functional.test_project_config.TestProjectConfig testMethod=test_set_sstate_dir>>) return self.run(*args, **kwds) Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com> --- .../tests/functional/test_project_config.py | 164 +++++++++--------- 1 file changed, 85 insertions(+), 79 deletions(-)