mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 16:56:30 -06:00
Fix template paths for Windows. Fixes #3139
Joint work from Joao and Murtuza.
This commit is contained in:
parent
9365ab62fe
commit
156b308fd3
@ -133,7 +133,7 @@ class ExternalTablesView(PGChildNodeView):
|
||||
did=kwargs['database_id']
|
||||
)
|
||||
self.sql_template_path = compile_template_path(
|
||||
'sql/',
|
||||
'sql',
|
||||
self.manager.server_type,
|
||||
self.manager.sversion
|
||||
)
|
||||
|
@ -7,6 +7,7 @@
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from pgadmin.browser.server_groups.servers.databases.external_tables import \
|
||||
@ -68,7 +69,9 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
connection=MagicMock(execute_2darray=MagicMock()),
|
||||
execute_2darray_return_value=(True, dict(rows=[])),
|
||||
|
||||
expect_render_template_called_with='sql/#gpdb#80323#/list.sql',
|
||||
expect_render_template_called_with=os.path.join('sql',
|
||||
'#gpdb#80323#',
|
||||
'list.sql'),
|
||||
expected_make_json_response_called_with=dict(
|
||||
data=[],
|
||||
status=200
|
||||
@ -90,7 +93,9 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
connection=MagicMock(execute_2darray=MagicMock()),
|
||||
execute_2darray_return_value=(False, 'Some error message'),
|
||||
|
||||
expect_render_template_called_with='sql/#gpdb#80323#/list.sql',
|
||||
expect_render_template_called_with=os.path.join('sql',
|
||||
'#gpdb#80323#',
|
||||
'list.sql'),
|
||||
expected_internal_server_error_called_with=dict(
|
||||
errormsg='Some error message'
|
||||
),
|
||||
@ -122,7 +127,9 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
]
|
||||
)),
|
||||
|
||||
expect_render_template_called_with='sql/#gpdb#80323#/list.sql',
|
||||
expect_render_template_called_with=os.path.join('sql',
|
||||
'#gpdb#80323#',
|
||||
'list.sql'),
|
||||
expected_make_json_response_called_with=dict(
|
||||
data=[
|
||||
{
|
||||
@ -167,7 +174,9 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
execute_2darray_return_value=(False, 'Some error message'),
|
||||
|
||||
expect_render_template_called_with=dict(
|
||||
template_name_or_list='sql/#gpdb#80323#/node.sql',
|
||||
template_name_or_list=os.path.join('sql',
|
||||
'#gpdb#80323#',
|
||||
'node.sql'),
|
||||
external_table_id=11
|
||||
),
|
||||
expected_internal_server_error_called_with=dict(
|
||||
@ -192,7 +201,9 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
execute_2darray_return_value=(True, dict(rows=[])),
|
||||
|
||||
expect_render_template_called_with=dict(
|
||||
template_name_or_list='sql/#gpdb#80323#/node.sql',
|
||||
template_name_or_list=os.path.join('sql',
|
||||
'#gpdb#80323#',
|
||||
'node.sql'),
|
||||
external_table_id=11
|
||||
),
|
||||
expected_make_json_response_called_with=dict(
|
||||
@ -229,7 +240,9 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
)),
|
||||
|
||||
expect_render_template_called_with=dict(
|
||||
template_name_or_list='sql/#gpdb#80323#/node.sql',
|
||||
template_name_or_list=os.path.join('sql',
|
||||
'#gpdb#80323#',
|
||||
'node.sql'),
|
||||
external_table_id=11
|
||||
),
|
||||
expected_make_json_response_called_with=dict(
|
||||
@ -283,8 +296,11 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
)),
|
||||
|
||||
expect_render_template_called_with=dict(
|
||||
template_name_or_list='sql/#gpdb#80323#/'
|
||||
'get_table_information.sql',
|
||||
template_name_or_list=os.path.join(
|
||||
'sql',
|
||||
'#gpdb#80323#',
|
||||
'get_table_information.sql'
|
||||
),
|
||||
table_oid=11
|
||||
),
|
||||
expected_make_response_called_with=dict(
|
||||
|
@ -117,20 +117,26 @@ class FakeApp(Flask):
|
||||
self.jinja_env.filters['qtTypeIdent'] = driver.qtTypeIdent
|
||||
self.jinja_loader = ChoiceLoader([
|
||||
FileSystemLoader(
|
||||
os.path.dirname(
|
||||
os.path.realpath(__file__)) + '/../templates/'
|
||||
os.path.join(os.path.dirname(
|
||||
os.path.realpath(__file__)
|
||||
), os.pardir, 'templates')
|
||||
),
|
||||
FileSystemLoader(
|
||||
os.path.dirname(
|
||||
os.path.realpath(__file__)) + '/../../templates/'
|
||||
os.path.join(
|
||||
os.path.dirname(
|
||||
os.path.realpath(__file__)
|
||||
), os.pardir, os.pardir, 'templates')
|
||||
),
|
||||
FileSystemLoader(
|
||||
os.path.dirname(
|
||||
os.path.realpath(__file__)) + '/../../types/templates/'
|
||||
os.path.join(os.path.dirname(
|
||||
os.path.realpath(__file__)),
|
||||
os.pardir, os.pardir, 'types', 'templates')
|
||||
),
|
||||
FileSystemLoader(
|
||||
os.path.dirname(
|
||||
os.path.realpath(__file__)) + '/../../../../templates/'
|
||||
os.path.join(os.path.dirname(
|
||||
os.path.realpath(__file__)),
|
||||
os.pardir, os.pardir, os.pardir, os.pardir,
|
||||
'templates')
|
||||
),
|
||||
]
|
||||
)
|
||||
|
@ -11,10 +11,12 @@ import os
|
||||
|
||||
def compile_template_name(
|
||||
template_prefix, template_file_name, server_type, version):
|
||||
return os.path.join(
|
||||
compile_template_path(template_prefix, server_type, version),
|
||||
template_file_name
|
||||
)
|
||||
|
||||
# Template path concatenation should be same as
|
||||
# Ref: ../pgadmin4/web/pgadmin/utils/versioned_template_loader.py +54
|
||||
# to avoid path mismatch in windows
|
||||
return compile_template_path(template_prefix, server_type, version) + \
|
||||
'/' + template_file_name
|
||||
|
||||
|
||||
def compile_template_path(template_prefix, server_type, version):
|
||||
@ -22,4 +24,8 @@ def compile_template_path(template_prefix, server_type, version):
|
||||
version_path = '#{0}#{1}#'.format(server_type, version)
|
||||
else:
|
||||
version_path = '#{0}#'.format(version)
|
||||
return os.path.join(template_prefix, version_path)
|
||||
|
||||
# Template path concatenation should be same as
|
||||
# Ref: ../pgadmin4/web/pgadmin/utils/versioned_template_loader.py +54
|
||||
# to avoid path mismatch in windows
|
||||
return template_prefix + '/' + version_path
|
||||
|
Loading…
Reference in New Issue
Block a user