-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: optimised options
by moving all getters
and setters
to custom descriptors
#882
Conversation
|
I always appreciate PRs that remove more code than add. Although I would still prefer to see a version first where typing works as expected and proper docstrings are present for each capability. |
@mykola-mokhnach I hope I have fixed all most all the review comments, please feel free to let me know in case anything needs to be modified. |
test/unit/junit.xml
Outdated
@@ -0,0 +1 @@ | |||
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="122" time="5.144" timestamp="2023-07-03T22:03:51.611198" hostname="Sandeeps-MacBook-Pro.local"><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_reset" time="0.020" /><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_install_app" time="0.018" /><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_remove_app" time="0.019" /><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_app_installed" time="0.034" /><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_terminate_app" time="0.055" /><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_activate_app" time="0.205" /><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_background_app" time="0.025" /><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_launch_app" time="0.076" /><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_close_app" time="0.045" /><testcase classname="unit.webdriver.app_test.TestWebDriverApp" name="test_query_app_state" time="0.061" /><testcase classname="unit.webdriver.appium_service_test.TestAppiumService" name="test_get_instance" time="0.003" /><testcase classname="unit.webdriver.context_test.TestWebDriverContext" name="test_get_contexts" time="0.045" /><testcase classname="unit.webdriver.execute_driver_test.TestWebDriverExecuteDriver" name="test_batch" time="0.034" /><testcase classname="unit.webdriver.execute_driver_test.TestWebDriverExecuteDriver" name="test_batch_with_timeout" time="0.053" /><testcase classname="unit.webdriver.ime_test.TestWebDriverIme" name="test_available_ime_engines" time="0.049" /><testcase classname="unit.webdriver.ime_test.TestWebDriverIme" name="test_is_ime_active" time="0.027" /><testcase classname="unit.webdriver.ime_test.TestWebDriverIme" name="test_activate_ime_engine" time="0.031" /><testcase classname="unit.webdriver.ime_test.TestWebDriverIme" name="test_deactivate_ime_engine" time="0.037" /><testcase classname="unit.webdriver.ime_test.TestWebDriverIme" name="test_active_ime_engine" time="0.026" /><testcase classname="unit.webdriver.log_events_test.TestWebDriverLogEvents" name="test_get_events" time="0.043" /><testcase classname="unit.webdriver.log_events_test.TestWebDriverLogEvents" name="test_get_events_args" time="0.030" /><testcase classname="unit.webdriver.log_events_test.TestWebDriverLogEvents" name="test_log_event" time="0.027" /><testcase classname="unit.webdriver.log_test.TestWebDriverLog" name="test_get_log_types" time="0.020" /><testcase classname="unit.webdriver.log_test.TestWebDriverLog" name="test_get_log" time="0.026" /><testcase classname="unit.webdriver.multi_action_test.TestMultiAction" name="test_json" time="0.002" /><testcase classname="unit.webdriver.nativekey_test.TestAndroidKey" name="test_has_some_codes" time="0.004" /><testcase classname="unit.webdriver.nativekey_test.TestAndroidKey" name="test_is_gamepad_key" time="0.009" /><testcase classname="unit.webdriver.nativekey_test.TestAndroidKey" name="test_is_confirm_key" time="0.003" /><testcase classname="unit.webdriver.nativekey_test.TestAndroidKey" name="test_is_media_key" time="0.002" /><testcase classname="unit.webdriver.nativekey_test.TestAndroidKey" name="test_is_system_key" time="0.003" /><testcase classname="unit.webdriver.nativekey_test.TestAndroidKey" name="test_is_wake_key" time="0.002" /><testcase classname="unit.webdriver.network_test.TestWebDriverNetwork" name="test_network_connection" time="0.041" /><testcase classname="unit.webdriver.network_test.TestWebDriverNetwork" name="test_set_network_connection" time="0.033" /><testcase classname="unit.webdriver.network_test.TestWebDriverNetwork" name="test_set_network_speed" time="0.028" /><testcase classname="unit.webdriver.network_test.TestWebDriverNetwork" name="test_toggle_wifi" time="0.051" /><testcase classname="unit.webdriver.performance_test.TestWebDriverPerformance" name="test_get_performance_data" time="0.017" /><testcase classname="unit.webdriver.performance_test.TestWebDriverPerformance" name="test_get_performance_data_types" time="0.013" /><testcase classname="unit.webdriver.screen_record_test.TestWebDriverScreenRecord" name="test_start_recording_screen" time="0.037" /><testcase classname="unit.webdriver.screen_record_test.TestWebDriverScreenRecord" name="test_stop_recording_screen" time="0.041" /><testcase classname="unit.webdriver.settings_test.TestWebDriverSettings" name="test_get_settings_bool" time="0.025" /><testcase classname="unit.webdriver.settings_test.TestWebDriverSettings" name="test_update_settings_bool" time="0.022" /><testcase classname="unit.webdriver.settings_test.TestWebDriverSettings" name="test_get_settings_string" time="0.017" /><testcase classname="unit.webdriver.settings_test.TestWebDriverSettings" name="test_update_settings_string" time="0.017" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_tap_json" time="0.006" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_tap_x_y_json" time="0.009" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_press_json" time="0.002" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_press_pressure_json" time="0.004" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_press_x_y_json" time="0.002" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_long_press_json" time="0.002" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_long_press_x_y_json" time="0.005" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_wait_json" time="0.002" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_wait_without_ms_json" time="0.019" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_move_to_json" time="0.013" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_release_json" time="0.004" /><testcase classname="unit.webdriver.touch_action_test.TestTouchAction" name="test_perform_json" time="0.011" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_create_session" time="0.023" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_create_session_change_session_id" time="0.038" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_create_session_register_uridirect" time="0.047" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_create_session_register_uridirect_no_direct_connect_path" time="0.036" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_get_all_sessions" time="0.030" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_get_session" time="0.032" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_get_events" time="0.027" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_get_events_catches_missing_events" time="0.030" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_session_catches_error" time="0.051" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_add_command" time="0.019" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_add_command_body" time="0.021" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_add_command_with_element_id" time="0.018" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_create_session_with_custom_connection" time="0.026" /><testcase classname="unit.webdriver.webdriver_test.TestWebDriverWebDriver" name="test_create_session_with_custom_connection_with_keepalive" time="0.014" /><testcase classname="unit.webdriver.webdriver_test.TestSubModuleWebDriver" name="test_clipboard_with_subclass" time="0.016" /><testcase classname="unit.webdriver.webdriver_test.TestSubModuleWebDriver" name="test_clipboard_with_subsubclass" time="0.016" /><testcase classname="unit.webdriver.webdriver_test.TestSubModuleWebDriver" name="test_compare_commands" time="0.038" /><testcase classname="unit.webdriver.webelement_test.TestWebElement" name="test_status" time="0.029" /><testcase classname="unit.webdriver.webelement_test.TestWebElement" name="test_set_value" time="0.030" /><testcase classname="unit.webdriver.webelement_test.TestWebElement" name="test_send_key" time="0.030" /><testcase classname="unit.webdriver.webelement_test.TestWebElement" name="test_send_key_with_file" time="0.041" /><testcase classname="unit.webdriver.webelement_test.TestWebElement" name="test_get_attribute_with_dict" time="0.020" /><testcase classname="unit.webdriver.device.activities_test.TestWebDriverActivities" name="test_current_activity" time="0.028" /><testcase classname="unit.webdriver.device.activities_test.TestWebDriverActivities" name="test_wait_activity" time="0.033" /><testcase classname="unit.webdriver.device.clipboard_test.TestWebDriverClipboard" name="test_set_clipboard_with_url" time="0.016" /><testcase classname="unit.webdriver.device.clipboard_test.TestWebDriverClipboard" name="test_set_clipboard_text" time="0.016" /><testcase classname="unit.webdriver.device.common_test.TestWebDriverCommon" name="test_open_notifications" time="0.024" /><testcase classname="unit.webdriver.device.common_test.TestWebDriverCommon" name="test_current_package" time="0.024" /><testcase classname="unit.webdriver.device.device_time_test.TestWebDriverDeviceTime" name="test_device_time" time="0.016" /><testcase classname="unit.webdriver.device.device_time_test.TestWebDriverDeviceTime" name="test_get_device_time" time="0.022" /><testcase classname="unit.webdriver.device.device_time_test.TestWebDriverDeviceTime" name="test_get_formatted_device_time" time="0.018" /><testcase classname="unit.webdriver.device.display_test.TestWebDriverDisplay" name="test_get_display_density" time="0.021" /><testcase classname="unit.webdriver.device.fingerprint_test.TestWebDriverFingerprint" name="test_finger_print" time="0.020" /><testcase classname="unit.webdriver.device.gsm_test.TestWebDriveGsm" name="test_make_gsm_call" time="0.019" /><testcase classname="unit.webdriver.device.gsm_test.TestWebDriveGsm" name="test_set_gsm_signal" time="0.031" /><testcase classname="unit.webdriver.device.gsm_test.TestWebDriveGsm" name="test_set_gsm_voice" time="0.023" /><testcase classname="unit.webdriver.device.keyboard_test.TestWebDriverKeyboard" name="test_hide_keyboard" time="0.033" /><testcase classname="unit.webdriver.device.keyboard_test.TestWebDriverKeyboard" name="test_press_keycode" time="0.021" /><testcase classname="unit.webdriver.device.keyboard_test.TestWebDriverKeyboard" name="test_long_press_keycode" time="0.028" /><testcase classname="unit.webdriver.device.keyboard_test.TestWebDriverKeyboard" name="test_keyevent" time="0.029" /><testcase classname="unit.webdriver.device.keyboard_test.TestWebDriverKeyboard" name="test_press_keycode_with_flags" time="0.027" /><testcase classname="unit.webdriver.device.keyboard_test.TestWebDriverKeyboard" name="test_long_press_keycode_with_flags" time="0.018" /><testcase classname="unit.webdriver.device.location_test.TestWebDriverLocation" name="test_toggle_location_services" time="0.021" /><testcase classname="unit.webdriver.device.location_test.TestWebDriverLocation" name="test_set_location_float" time="0.023" /><testcase classname="unit.webdriver.device.location_test.TestWebDriverLocation" name="test_set_location_str" time="0.018" /><testcase classname="unit.webdriver.device.location_test.TestWebDriverLocation" name="test_set_location_without_altitude" time="0.021" /><testcase classname="unit.webdriver.device.location_test.TestWebDriverLocation" name="test_set_location_without_speed" time="0.023" /><testcase classname="unit.webdriver.device.location_test.TestWebDriverLocation" name="test_location" time="0.033" /><testcase classname="unit.webdriver.device.lock_test.TestWebDriverLock" name="test_lock" time="0.033" /><testcase classname="unit.webdriver.device.lock_test.TestWebDriverLock" name="test_lock_no_args" time="0.025" /><testcase classname="unit.webdriver.device.lock_test.TestWebDriverLock" name="test_islocked_false" time="0.037" /><testcase classname="unit.webdriver.device.lock_test.TestWebDriverLock" name="test_islocked_true" time="0.041" /><testcase classname="unit.webdriver.device.lock_test.TestWebDriverLock" name="test_unlock" time="0.028" /><testcase classname="unit.webdriver.device.power_test.TestWebDriverPower" name="test_set_power_capacity" time="0.025" /><testcase classname="unit.webdriver.device.power_test.TestWebDriverPower" name="test_set_power_ac" time="0.023" /><testcase classname="unit.webdriver.device.remote_fs_test.TestWebDriverRemoteFs" name="test_push_file" time="0.034" /><testcase classname="unit.webdriver.device.remote_fs_test.TestWebDriverRemoteFs" name="test_push_file_invalid_arg_exception_without_src_path_and_base64data" time="0.014" /><testcase classname="unit.webdriver.device.remote_fs_test.TestWebDriverRemoteFs" name="test_push_file_invalid_arg_exception_with_src_file_not_found" time="0.015" /><testcase classname="unit.webdriver.device.remote_fs_test.TestWebDriverRemoteFs" name="test_pull_file" time="0.025" /><testcase classname="unit.webdriver.device.remote_fs_test.TestWebDriverRemoteFs" name="test_pull_folder" time="0.021" /><testcase classname="unit.webdriver.device.shake_test.TestWebDriverShake" name="test_shake" time="0.020" /><testcase classname="unit.webdriver.device.sms_test.TestWebDriverSms" name="test_send_sms" time="0.021" /><testcase classname="unit.webdriver.device.system_bars_test.TestWebDriverSystemBars" name="test_get_system_bars" time="0.020" /><testcase classname="unit.webdriver.search_context.android_test.TestWebDriverAndroidSearchContext" name="test_find_element_by_android_data_matcher" time="0.023" /><testcase classname="unit.webdriver.search_context.android_test.TestWebDriverAndroidSearchContext" name="test_find_elements_by_android_data_matcher" time="0.023" /><testcase classname="unit.webdriver.search_context.android_test.TestWebDriverAndroidSearchContext" name="test_find_elements_by_android_data_matcher_no_value" time="0.018" /><testcase classname="unit.webdriver.search_context.windows_test.TestWebDriverWindowsSearchContext" name="test_find_element_by_windows_uiautomation" time="0.032" /></testsuite></testsuites> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be excluded?
In
appium/options
, there were tons and tons of python modules with hundreds ofproperties
.If we carefully observe the
getters
andsetters
, allgetters
are callingget_capabilites
method and all setter methods are callingset_capabilites
method (with some exceptions for for attributes).I could see that there is lot of boiler plate code in the entire
options
package.There is lot scope for optimisation and I have done it by eliminating
properties
by custom datadescriptors
.Custom Descriptors are most efficient and ideal in this case where it eliminates multiple tons of
getters
andsetters
.Now the
options
folder looks more light weight.I am still working on docstings and other lynting stuff for the changes that I have made. I will be updating this PR with final version of the code in next 24 hrs.
Mean while let me know your thoughts on the changes that I have made.