From 633926569264326e014cc777fbea4f63f180b6eb Mon Sep 17 00:00:00 2001 From: Paul McKeown Date: Tue, 5 Mar 2024 16:25:20 +1300 Subject: [PATCH] Reverted behat fixtures to roughly what they were with minor improvements. Removed unneccesary Given jobe sandbox enabled lines. Removed the hack in jobesandbox.php in prep for merging with branch that has fixed the problem of reverting back to coderunner's default jobe2 server (jobe2.cosc.canterbury.ac.nz) during bhat tests. --- classes/jobesandbox.php | 24 +------------------ tests/behat/attachmentimportexport.feature | 3 +-- tests/behat/attachments.feature | 3 +-- tests/behat/backup_and_restore.feature | 3 +-- tests/behat/behat_coderunner.php | 5 ---- .../behat/check_graph_question_types.feature | 3 +-- .../check_python_template_params.feature | 3 +-- tests/behat/check_stepinfo.feature | 3 +-- .../behat/check_twig_student_variable.feature | 3 +-- .../behat/create_python3_sqr_function.feature | 3 +-- tests/behat/duplicate_prototype.feature | 3 +-- tests/behat/edit.feature | 3 +-- tests/behat/edit_question_precheck.feature | 3 +-- tests/behat/edit_table.feature | 3 +-- tests/behat/export.feature | 3 +-- tests/behat/gapfiller_ui.feature | 3 +-- tests/behat/grading_scenarios.feature | 3 +-- tests/behat/html_ui.feature | 3 +-- tests/behat/import.feature | 3 +-- tests/behat/make_combinator_prototype.feature | 3 +-- tests/behat/make_prototype.feature | 3 +-- tests/behat/missing_prototype.feature | 3 +-- tests/behat/reset_button.feature | 3 +-- tests/behat/run_python3_sqr_function.feature | 3 +-- ...run_python3_sqr_function_templated.feature | 3 +-- tests/behat/sandbox_webservice.feature | 2 +- tests/behat/scratchpad_ui_params.feature | 4 ++-- tests/behat/set_uiplugin.feature | 3 +-- tests/behat/showdifferences_button.feature | 3 +-- tests/behat/template_params_error.feature | 3 +-- tests/behat/twigprefix.feature | 3 +-- 31 files changed, 31 insertions(+), 85 deletions(-) diff --git a/classes/jobesandbox.php b/classes/jobesandbox.php index d410b41e4..1eba4ac09 100644 --- a/classes/jobesandbox.php +++ b/classes/jobesandbox.php @@ -73,29 +73,7 @@ class qtype_coderunner_jobesandbox extends qtype_coderunner_sandbox { public function __construct() { global $CFG; qtype_coderunner_sandbox::__construct(); - - // Hack to force use of a local jobe host when behat testing. - // if ($CFG->prefix == "bht_") { - // $this->jobeserver = "localhost"; // Should it be :4000 ? - // } else if ($CFG->prefix == "b_") { - // $this->jobeserver = "172.17.0.1:4000"; // For local moodle-docker usage. - // } else { - // $this->jobeserver = get_config('qtype_coderunner', 'jobe_host'); - // } - - // use Given the CodeRunner jobe sandbox is enabled - // or Given the CodeRunner jobe scratchpad is enabled - // in each feature to make sure the right jobe_host string is used - // adjust behat_coderunner.php to set the appropriate server - // eg, in a local docker we usually have 172.17.0.1:4000 - - $jobefromconfig = get_config('qtype_coderunner', 'jobe_host'); - $this->jobeserver = $jobefromconfig; - $keyenabled = get_config('qtype_coderunner', 'jobe_apikey_enabled'); - // $this->jobeserver = $jobefromconfig; - if ($jobefromconfig != "172.17.0.1:4000") { - $banana = 'what?'; - } + $this->jobeserver = get_config('qtype_coderunner', 'jobe_host'); $this->apikey = get_config('qtype_coderunner', 'jobe_apikey'); $this->languages = null; } diff --git a/tests/behat/attachmentimportexport.feature b/tests/behat/attachmentimportexport.feature index 1b96a9f92..1150d4c56 100644 --- a/tests/behat/attachmentimportexport.feature +++ b/tests/behat/attachmentimportexport.feature @@ -5,8 +5,7 @@ Feature: Test importing and exporting of question with attachments I need to be able to import and export them Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | | teacher | And the following "courses" exist: diff --git a/tests/behat/attachments.feature b/tests/behat/attachments.feature index 3a25de6cf..2403b336d 100644 --- a/tests/behat/attachments.feature +++ b/tests/behat/attachments.feature @@ -5,8 +5,7 @@ Feature: Test editing and using attachments to a CodeRunner question I need to enable and configure them, then preview them. Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/backup_and_restore.feature b/tests/behat/backup_and_restore.feature index 6b183b60d..8d3d73552 100644 --- a/tests/behat/backup_and_restore.feature +++ b/tests/behat/backup_and_restore.feature @@ -5,8 +5,7 @@ Feature: Duplicate a course containing a CodeRunner question I need to be able to back them up and restore them Background: - Given the CodeRunner jobe sandbox is enabled - And the following "courses" exist: + Given the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "question categories" exist: diff --git a/tests/behat/behat_coderunner.php b/tests/behat/behat_coderunner.php index 4cb756964..55d713d25 100644 --- a/tests/behat/behat_coderunner.php +++ b/tests/behat/behat_coderunner.php @@ -34,7 +34,6 @@ class behat_coderunner extends behat_base { */ public function the_coderunner_sandbox_is_enabled() { set_config('jobesandbox_enabled', 1, 'qtype_coderunner'); - set_config('jobe_host', '172.17.0.1:4000', 'qtype_coderunner'); } @@ -45,8 +44,6 @@ public function the_coderunner_sandbox_is_enabled() { */ public function the_coderunner_scratchpad_is_enabled() { set_config('wsenabled', 1, 'qtype_coderunner'); - set_config('jobesandbox_enabled', 1, 'qtype_coderunner'); - set_config('jobe_host', '172.17.0.1:4000', 'qtype_coderunner'); } @@ -57,8 +54,6 @@ public function the_coderunner_scratchpad_is_enabled() { */ public function the_coderunner_scratchpad_is_disabled() { set_config('wsenabled', 0, 'qtype_coderunner'); - set_config('jobesandbox_enabled', 1, 'qtype_coderunner'); - set_config('jobe_host', '172.17.0.1:4000', 'qtype_coderunner'); } diff --git a/tests/behat/check_graph_question_types.feature b/tests/behat/check_graph_question_types.feature index e20065e5d..8b65a60a4 100644 --- a/tests/behat/check_graph_question_types.feature +++ b/tests/behat/check_graph_question_types.feature @@ -5,8 +5,7 @@ Feature: Check that the directed and undirected graph question types work. I should be able to write simple graph questions and have them work correctly Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/check_python_template_params.feature b/tests/behat/check_python_template_params.feature index e52ed874b..14955b0cd 100644 --- a/tests/behat/check_python_template_params.feature +++ b/tests/behat/check_python_template_params.feature @@ -5,8 +5,7 @@ Feature: Check that Python and other languages can be used instead of Twig as a I should be able to write a function that prints the seed and my username it should be marked right Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | Last | teacher1@asd.com | | student1 | Student First | O'Connell | student@asd.com | diff --git a/tests/behat/check_stepinfo.feature b/tests/behat/check_stepinfo.feature index 125712c39..69ebbc82d 100644 --- a/tests/behat/check_stepinfo.feature +++ b/tests/behat/check_stepinfo.feature @@ -5,8 +5,7 @@ Feature: Check that the QUESTION.stepinfo record is working. I should be able to write a question that gives different feedback for different submissions. Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | | student1 | Student | 1 | student@asd.com | diff --git a/tests/behat/check_twig_student_variable.feature b/tests/behat/check_twig_student_variable.feature index 74c5b974d..7d011155b 100644 --- a/tests/behat/check_twig_student_variable.feature +++ b/tests/behat/check_twig_student_variable.feature @@ -5,8 +5,7 @@ Feature: Check the STUDENT Twig variable allows access to current username in Co I should be able to write a function that prints my username it should be marked right Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | | student1 | Student | 1 | student@asd.com | diff --git a/tests/behat/create_python3_sqr_function.feature b/tests/behat/create_python3_sqr_function.feature index 4a938710a..e459fc9e9 100644 --- a/tests/behat/create_python3_sqr_function.feature +++ b/tests/behat/create_python3_sqr_function.feature @@ -5,8 +5,7 @@ Feature: Create a CodeRunner question (the sqr function example) I need to create a new CodeRunner question Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/duplicate_prototype.feature b/tests/behat/duplicate_prototype.feature index fa32eedc6..7ff68ced9 100644 --- a/tests/behat/duplicate_prototype.feature +++ b/tests/behat/duplicate_prototype.feature @@ -5,8 +5,7 @@ Feature: duplicate_prototypes I should see an informative error message and be able to fix by editing the duplicates Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/edit.feature b/tests/behat/edit.feature index 41a34a7df..db79a1747 100644 --- a/tests/behat/edit.feature +++ b/tests/behat/edit.feature @@ -5,8 +5,7 @@ Feature: Test editing a CodeRunner question I need to edit them Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/edit_question_precheck.feature b/tests/behat/edit_question_precheck.feature index 9ae276c55..29ee74e74 100644 --- a/tests/behat/edit_question_precheck.feature +++ b/tests/behat/edit_question_precheck.feature @@ -5,8 +5,7 @@ Feature: edit_question_precheck I should get informative error messages if saving was unsuccessful Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/edit_table.feature b/tests/behat/edit_table.feature index 153150e6a..51371477e 100644 --- a/tests/behat/edit_table.feature +++ b/tests/behat/edit_table.feature @@ -5,8 +5,7 @@ Feature: Test editing a CodeRunner question using the Table UI I should be able to set the table headers and see the table in the edit form. Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/export.feature b/tests/behat/export.feature index 92c7a0faf..2180f4853 100644 --- a/tests/behat/export.feature +++ b/tests/behat/export.feature @@ -5,8 +5,7 @@ Feature: Export CodeRunner questions I need to export them Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | | teacher | And the following "courses" exist: diff --git a/tests/behat/gapfiller_ui.feature b/tests/behat/gapfiller_ui.feature index 537838eb5..58e6c783b 100644 --- a/tests/behat/gapfiller_ui.feature +++ b/tests/behat/gapfiller_ui.feature @@ -5,8 +5,7 @@ Feature: Test the GapFiller_UI I should be able specify the required gaps in the global extra or test0 fields Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/grading_scenarios.feature b/tests/behat/grading_scenarios.feature index 183f6209f..cb7602a3c 100644 --- a/tests/behat/grading_scenarios.feature +++ b/tests/behat/grading_scenarios.feature @@ -5,8 +5,7 @@ Feature: Check grading with the Python 3 sqr function CodeRunner question I must be able to preview them Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/html_ui.feature b/tests/behat/html_ui.feature index 3af90167b..b235bbcdf 100644 --- a/tests/behat/html_ui.feature +++ b/tests/behat/html_ui.feature @@ -5,8 +5,7 @@ Feature: Test the HTML_UI I should be able specify the required html in either globalextra or prototypeextra Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/import.feature b/tests/behat/import.feature index f760a2e09..01062935c 100644 --- a/tests/behat/import.feature +++ b/tests/behat/import.feature @@ -5,8 +5,7 @@ Feature: Import CodeRunner questions I need to import them Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | | teacher | And the following "courses" exist: diff --git a/tests/behat/make_combinator_prototype.feature b/tests/behat/make_combinator_prototype.feature index da68fe775..bfbc2d6be 100644 --- a/tests/behat/make_combinator_prototype.feature +++ b/tests/behat/make_combinator_prototype.feature @@ -5,8 +5,7 @@ Feature: make_combinator_prototype I must be able to create new combinator templates Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/make_prototype.feature b/tests/behat/make_prototype.feature index 386bef982..b1b1617f9 100644 --- a/tests/behat/make_prototype.feature +++ b/tests/behat/make_prototype.feature @@ -5,8 +5,7 @@ Feature: make_prototype I must be able to create new question templates Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/missing_prototype.feature b/tests/behat/missing_prototype.feature index d9d109c90..9eb2687bf 100644 --- a/tests/behat/missing_prototype.feature +++ b/tests/behat/missing_prototype.feature @@ -5,8 +5,7 @@ Feature: missing_prototype I should see an informative error message and be able to fix by editing Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/reset_button.feature b/tests/behat/reset_button.feature index c8da49a3b..fc215c1d4 100644 --- a/tests/behat/reset_button.feature +++ b/tests/behat/reset_button.feature @@ -5,8 +5,7 @@ Feature: Preview the Python 3 sqr function CodeRunner question with a preload I should see a Reset answer button that resets the preload, Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/run_python3_sqr_function.feature b/tests/behat/run_python3_sqr_function.feature index e2c45fff7..47c424af4 100644 --- a/tests/behat/run_python3_sqr_function.feature +++ b/tests/behat/run_python3_sqr_function.feature @@ -5,8 +5,7 @@ Feature: Preview the Python 3 sqr function CodeRunner question I must be able to preview them Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/run_python3_sqr_function_templated.feature b/tests/behat/run_python3_sqr_function_templated.feature index 82025d9c7..b40922694 100644 --- a/tests/behat/run_python3_sqr_function_templated.feature +++ b/tests/behat/run_python3_sqr_function_templated.feature @@ -5,8 +5,7 @@ Feature: Combinator template is called test-by-test if a runtime error occurs wh I need the combinator template to be used test-by-test if my answer gives a runtime error Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/sandbox_webservice.feature b/tests/behat/sandbox_webservice.feature index aa072a8c4..abc03e328 100644 --- a/tests/behat/sandbox_webservice.feature +++ b/tests/behat/sandbox_webservice.feature @@ -4,7 +4,7 @@ Feature: Test sandbox web service server (Jobe) via Ajax. Background: - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher | Teacher | 1 | teacher@asd.com | | student | Student | 1 | student@asd.com | diff --git a/tests/behat/scratchpad_ui_params.feature b/tests/behat/scratchpad_ui_params.feature index 57332da91..312f48894 100644 --- a/tests/behat/scratchpad_ui_params.feature +++ b/tests/behat/scratchpad_ui_params.feature @@ -5,7 +5,8 @@ Feature: Test the Scratchpad UI, UI Params I should be able specify the UI Parameters to change the Scratchpad UI Background: - Given the following "users" exist: + Given the CodeRunner scratchpad is enabled + And the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: @@ -20,7 +21,6 @@ Feature: Test the Scratchpad UI, UI Params And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | coderunner | Print answer | printans | - And the CodeRunner scratchpad is enabled And I am on the "Print answer" "core_question > edit" page logged in as teacher1 And I set the field "id_validateonsave" to "" diff --git a/tests/behat/set_uiplugin.feature b/tests/behat/set_uiplugin.feature index a39d11b3e..53f60b1d0 100644 --- a/tests/behat/set_uiplugin.feature +++ b/tests/behat/set_uiplugin.feature @@ -5,8 +5,7 @@ Feature: Check that a selected UI plugin is saved I should be able to select a UI plugin and save the form Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/showdifferences_button.feature b/tests/behat/showdifferences_button.feature index c63b496c7..c244167eb 100644 --- a/tests/behat/showdifferences_button.feature +++ b/tests/behat/showdifferences_button.feature @@ -5,8 +5,7 @@ Feature: Show differences in CodeRunner questions clicked. Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/template_params_error.feature b/tests/behat/template_params_error.feature index 543c6d942..bce676548 100644 --- a/tests/behat/template_params_error.feature +++ b/tests/behat/template_params_error.feature @@ -5,8 +5,7 @@ Feature: template_params_error I should get informative template parameter error messages Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: diff --git a/tests/behat/twigprefix.feature b/tests/behat/twigprefix.feature index 4df509257..86eb75637 100644 --- a/tests/behat/twigprefix.feature +++ b/tests/behat/twigprefix.feature @@ -5,8 +5,7 @@ Feature: twigprefix I must be able to use the Twig prefix data in a question. Background: - Given the CodeRunner jobe sandbox is enabled - And the following "users" exist: + Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@asd.com | And the following "courses" exist: