Infrastructure and changes to the Query Tool for realtime preference handling. Refs #3294

Highlights of this patch include:
- Changes will affect SQL Editors in Create dialog boxes, SQL tab of the main screen, Query tool, History entries in the query tool, Query tool opened in New Tab/Window
- All the components of SQL editor will refer to single source of preferences which is cached in the Browser object. All other redundant ajax get preference calls are removed.
- SQL editor will not refer template JS variables anymore, once all the references are removed the template variables will also be removed.
- Code refactoring wherever possible.
- Covered JS test cases wherever possible.
This commit is contained in:
Aditya Toshniwal
2018-07-05 11:38:43 +01:00
committed by Dave Page
parent 82d77c4608
commit bdb7e3fde2
24 changed files with 527 additions and 849 deletions

View File

@@ -1,100 +0,0 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2018, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
from pgadmin.utils.route import BaseTestGenerator
from pgadmin.tools.sqleditor.utils.query_tool_preferences import \
get_text_representation_of_shortcut
class TestQueryToolPreference(BaseTestGenerator):
"""
Ensures that we are able to fetch preferences properly
"""
scenarios = [
('Check text representation of a valid shortcuts', dict(
fetch_pref=True,
sample_shortcut=dict(
alt=False,
shift=False,
control=False,
key=dict(
char='a',
keyCode=65
)
),
expected_result='a'
)),
('Check text representation of a valid shortcuts', dict(
fetch_pref=True,
sample_shortcut=dict(
alt=True,
shift=False,
control=False,
key=dict(
char='a',
keyCode=65
)
),
expected_result='Alt+a'
)),
('Check text representation of a valid shortcuts', dict(
fetch_pref=True,
sample_shortcut=dict(
alt=True,
shift=True,
control=True,
key=dict(
char='a',
keyCode=65
)
),
expected_result='Alt+Shift+Ctrl+a'
)),
('Check text representation of a valid shortcuts', dict(
fetch_pref=True,
sample_shortcut=dict(
alt=False,
shift=True,
control=False,
key=dict(
char='a',
keyCode=65
)
),
expected_result='Shift+a'
)),
('Check text representation of a valid shortcuts', dict(
fetch_pref=True,
sample_shortcut=dict(
alt=True,
shift=True,
control=False,
key=dict(
char='a',
keyCode=65
)
),
expected_result='Alt+Shift+a'
)),
('Check text representation of a invalid shortcuts', dict(
fetch_pref=True,
sample_shortcut=None,
expected_result=''
))
]
def runTest(self):
"""Check correct function is called to handle to run query."""
result = get_text_representation_of_shortcut(self.sample_shortcut)
self.assertEquals(result, self.expected_result)