From d36fe6e0e475ff40151e6154112e11b0e2b681c7 Mon Sep 17 00:00:00 2001 From: Brian Foley Date: Fri, 29 Mar 2024 12:27:36 -0400 Subject: [PATCH] Add smoketests for tools/site_admin This now gives us basic coverage of almost all of the pages on PGDP. From here, we can start filling different action types and data to exercise different code paths. --- SETUP/smoketests/pageload_smoketest.py | 92 ++++++++++++++++++++------ SETUP/smoketests/smoketest_setup.sh | 1 + SETUP/smoketests/test_tables.sql | 33 +++++++++ 3 files changed, 107 insertions(+), 19 deletions(-) diff --git a/SETUP/smoketests/pageload_smoketest.py b/SETUP/smoketests/pageload_smoketest.py index 79c482a6d4..9d9184f4d9 100755 --- a/SETUP/smoketests/pageload_smoketest.py +++ b/SETUP/smoketests/pageload_smoketest.py @@ -395,6 +395,77 @@ {'path': 'tools/proofers/round.php?round_id=P3'}, {'path': 'tools/proofers/srchrep.php'}, ] +TOOLS_SITE_ADMIN_TESTS = [ + {'path': 'tools/site_admin/convert_project_table_utf8.php?projectid=projectID5e23a810ef693'}, + { + 'method': 'POST', + 'path': 'tools/site_admin/copy_pages.php', + 'data': { + 'projectid_[from]': 'projectID5e23a810ef693', + 'projectid_[to]': 'projectID3141592653589', + 'from_image_[lo]': '004.png', + 'from_image_[hi]': '005.png', + 'page_name_handling': 'RENUMBER_PAGES', + 'transfer_notifications': 0, + 'add_deletion_reason': 0, + 'merge_wordcheck_data': 0, + 'repeat_project': 'NONE', + 'action': 'docopy', + }, + }, + { + 'method': 'POST', + 'path': 'tools/site_admin/delete_pages.php', + 'data': { + 'projectid': 'projectID5e23a810ef693', + 'from_image_[lo]': '004.png', + 'from_image_[hi]': '005.png', + 'action': 'check', + }, + }, + # TODO Needs rules table to be useful + {'path': 'tools/site_admin/displayrandrules.php'}, + # TODO Needs rules table to be useful + {'path': 'tools/site_admin/manage_random_rules.php'}, + # TODO Needs a non-activated user to be useful + {'path': 'tools/site_admin/edit_mail_address_for_non_activated_user.php'}, + {'path': 'tools/site_admin/index.php'}, + {'path': 'tools/site_admin/manage_site_access_privileges.php?username=teststeel'}, + {'path': 'tools/site_admin/manage_site_charsuites.php'}, + # TODO Needs some site wordlists + {'path': 'tools/site_admin/manage_site_word_lists.php'}, + # TODO Needs some special day entries + {'path': 'tools/site_admin/manage_special_days.php'}, + { + 'method': 'POST', + 'path': 'tools/site_admin/project_jump.php', + 'data': { + 'projectid': 'projectID5e23a810ef693', + 'new_state': 'F2.proj_unavail', + 'action': 'check', + }, + }, + {'path': 'tools/site_admin/projects_with_odd_values.php'}, + {'path': 'tools/site_admin/rename_pages.php?projectid=projectID3141592653589'}, + { + 'method': 'POST', + 'path': 'tools/site_admin/rename_pages.php', + 'data': { + 'projectid': 'projectID3141592653589', + 'renumber_from_n': 'on', + 'renumbering_start': 123, + 'submit_button': 'Check renamings', + }, + }, + # TODO Needs conflicts to be useful + {'path': 'tools/site_admin/shared_postednums.php'}, + # TODO Needs access_log entries to be useful + {'path': 'tools/site_admin/show_access_log.php'}, + # TODO Needs overlapping word lists to be useful + {'path': 'tools/site_admin/show_common_words_from_project_word_lists.php'}, + # TODO Needs news_items to be useful + {'path': 'tools/site_admin/sitenews.php'}, +] TESTS = ( NOLOGIN_TESTS + @@ -410,27 +481,10 @@ TOOLS_AUTHORS_TESTS + TOOLS_POST_PROOFERS_TESTS + TOOLS_PROJECT_MANAGER_TESTS + - TOOLS_PROOFERS_TESTS + TOOLS_PROOFERS_TESTS + + TOOLS_SITE_ADMIN_TESTS ) -# {'path': 'tools/site_admin/convert_project_table_utf8.php'}, -# {'path': 'tools/site_admin/copy_pages.php'}, -# {'path': 'tools/site_admin/delete_pages.php'}, -# {'path': 'tools/site_admin/displayrandrules.php'}, -# {'path': 'tools/site_admin/edit_mail_address_for_non_activated_user.php'}, -# {'path': 'tools/site_admin/index.php'}, -# {'path': 'tools/site_admin/manage_random_rules.php'}, -# {'path': 'tools/site_admin/manage_site_access_privileges.php'}, -# {'path': 'tools/site_admin/manage_site_charsuites.php'}, -# {'path': 'tools/site_admin/manage_site_word_lists.php'}, -# {'path': 'tools/site_admin/manage_special_days.php'}, -# {'path': 'tools/site_admin/project_jump.php'}, -# {'path': 'tools/site_admin/projects_with_odd_values.php'}, -# {'path': 'tools/site_admin/rename_pages.php'}, -# {'path': 'tools/site_admin/shared_postednums.php'}, -# {'path': 'tools/site_admin/show_access_log.php'}, -# {'path': 'tools/site_admin/show_common_words_from_project_word_lists.php'}, -# {'path': 'tools/site_admin/sitenews.php'}, def get_site_config() -> dict: config = {} diff --git a/SETUP/smoketests/smoketest_setup.sh b/SETUP/smoketests/smoketest_setup.sh index 9a7dc81e55..91331fbc95 100755 --- a/SETUP/smoketests/smoketest_setup.sh +++ b/SETUP/smoketests/smoketest_setup.sh @@ -8,3 +8,4 @@ mkdir -p "${HOME}/projects/projectID5e23a810ef693" for i in 001 002 003 004 005 illo; do cp SETUP/smoketests/dot.png "${HOME}/projects/projectID5e23a810ef693/${i}.png" done +mkdir -p "${HOME}/projects/projectID3141592653589" diff --git a/SETUP/smoketests/test_tables.sql b/SETUP/smoketests/test_tables.sql index 8cdc702b4e..f3c1475627 100644 --- a/SETUP/smoketests/test_tables.sql +++ b/SETUP/smoketests/test_tables.sql @@ -5,6 +5,7 @@ SET FOREIGN_KEY_CHECKS=0; * to be created with programmatic control of the project_id. */ REPLACE INTO `projects` VALUES ('*UTF-8 Practice','Lummis, Charles Fletcher','English','admin','notes','html','projectID5e23a810ef693','','',1704080514,1579564017,1579395673,1708309119,'','P3.proj_avail',NULL,'20200118BEGIN001','',417,1,0,'Folklore','beginner',0,'','',15,6,NULL,'TESTING','admin','admin','',0,'',''); +REPLACE INTO `projects` VALUES ('An Empty Project','Fletcher, Jessica','English','admin','notes','html','projectID3141592653589','','',1704080514,1579564017,1579395673,1708309119,'','P3.proj_avail',NULL,'20200118BEGIN001','',417,1,0,'History','beginner',0,'','',15,6,NULL,'TESTING','admin','admin','',0,'',''); /* `users` rows populated by INSERTs in accounts/activate.php. * Can't do this programatically yet. @@ -73,3 +74,35 @@ REPLACE INTO `projectID5e23a810ef693` VALUES ('002','002.png','THE MAN WHO MARRI REPLACE INTO `projectID5e23a810ef693` VALUES ('003','003.png','Copyright, 1891, 1892, 1894,\r\n\r\nBy THE CENTURY C0.\r\n\r\n\r\n\r\nTHE DEVINNE PREss;',1579633720,'sanspeur43','Copyright, 1891, 1892, 1894,\r\nBy THE CENTURY Co.\r\n\r\n\r\n\r\nTHE DE VINNE PREss.',1579651130,'jjz','\r\nCopyright, 1891, 1892, 1894,\r\nBy THE CENTURY Co.\r\n\r\nTHE DE VINNE PREss.',1708308890,'srjfoo','\r\nCopyright, 1891, 1892, 1894,\r\nBy THE CENTURY Co.\r\n\r\nThe De Vinne Press.',0,'','',0,'','','P3.page_saved','',0,''); REPLACE INTO `projectID5e23a810ef693` VALUES ('004','004.png','To\r\nTHE FAIRY TALE THAT CAME TRUE IN\r\nTHE HOME OF THE TEE-WAHN\r\nMY WIFE AND CHILD',1579633808,'sanspeur43','To\r\nTHE FAIRY TALE THAT CAME TRUE IN\r\nTHE HOME OF THE TEE-WAHN\r\nMY WIFE AND CHILD',1579651187,'jjz','\r\nTo\r\nTHE FAIRY TALE THAT CAME TRUE IN\r\nTHE HOME OF THE TEE-WAHN\r\nMY WIFE AND CHILD',1708308955,'srjfoo','\r\nTo\r\nTHE FAIRY TALE THAT CAME TRUE IN\r\nTHE HOME OF THE TEE-WAHN\r\nMY WIFE AND CHILD',0,'','',0,'','','P3.page_saved','',0,''); REPLACE INTO `projectID5e23a810ef693` VALUES ('005','005.png','',1579633830,'sanspeur43','[Blank Page]',1579651201,'jjz','[Blank Page]',1708308967,'srjfoo','[Blank Page]',0,'','',0,'','','P3.page_saved','',0,''); + +DROP TABLE IF EXISTS `projectID3141592653589`; +CREATE TABLE `projectID3141592653589` ( + fileid varchar(20) NOT NULL DEFAULT '', UNIQUE (fileid), + image varchar(12) NOT NULL DEFAULT '', UNIQUE (image), + master_text longtext NOT NULL, + round1_time int NOT NULL DEFAULT '0', + round1_user varchar(25) NOT NULL DEFAULT '', + round1_text longtext NOT NULL, + round2_time int NOT NULL DEFAULT '0', + round2_user varchar(25) NOT NULL DEFAULT '', + round2_text longtext COLLATE utf8mb4_general_ci NOT NULL, + round3_time int NOT NULL DEFAULT '0', + round3_user varchar(25) NOT NULL DEFAULT '', + round3_text longtext NOT NULL, + round4_time int NOT NULL DEFAULT '0', + round4_user varchar(25) NOT NULL DEFAULT '', + round4_text longtext NOT NULL, + round5_time int NOT NULL DEFAULT '0', + round5_user varchar(25) NOT NULL DEFAULT '', + round5_text longtext NOT NULL, + state varchar(50) NOT NULL DEFAULT '', + b_user varchar(25) NOT NULL DEFAULT '', + b_code int NOT NULL DEFAULT '0', + orig_page_num varchar(6) NOT NULL DEFAULT '', + KEY round1_user (round1_user), + KEY round2_user (round2_user), + KEY round3_user (round3_user), + KEY round4_user (round4_user), + KEY round5_user (round5_user), + KEY state (state) +) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;