mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix template handling in tests for Windows.
This commit is contained in:
parent
bc4d16eb83
commit
ab27b9d118
@ -69,9 +69,8 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
connection=MagicMock(execute_2darray=MagicMock()),
|
||||
execute_2darray_return_value=(True, dict(rows=[])),
|
||||
|
||||
expect_render_template_called_with=os.path.join('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
|
||||
@ -93,9 +92,8 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
connection=MagicMock(execute_2darray=MagicMock()),
|
||||
execute_2darray_return_value=(False, 'Some error message'),
|
||||
|
||||
expect_render_template_called_with=os.path.join('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'
|
||||
),
|
||||
@ -127,9 +125,8 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
]
|
||||
)),
|
||||
|
||||
expect_render_template_called_with=os.path.join('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=[
|
||||
{
|
||||
@ -174,9 +171,8 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
execute_2darray_return_value=(False, 'Some error message'),
|
||||
|
||||
expect_render_template_called_with=dict(
|
||||
template_name_or_list=os.path.join('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(
|
||||
@ -201,9 +197,8 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
execute_2darray_return_value=(True, dict(rows=[])),
|
||||
|
||||
expect_render_template_called_with=dict(
|
||||
template_name_or_list=os.path.join('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(
|
||||
@ -240,9 +235,8 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
)),
|
||||
|
||||
expect_render_template_called_with=dict(
|
||||
template_name_or_list=os.path.join('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(
|
||||
@ -297,10 +291,7 @@ class TestExternalTablesView(BaseTestGenerator):
|
||||
|
||||
expect_render_template_called_with=dict(
|
||||
template_name_or_list=os.path.join(
|
||||
'sql',
|
||||
'#gpdb#80323#',
|
||||
'get_table_information.sql'
|
||||
),
|
||||
'sql/#gpdb#80323#', 'get_table_information.sql'),
|
||||
table_oid=11
|
||||
),
|
||||
expected_make_response_called_with=dict(
|
||||
|
@ -20,7 +20,7 @@ else:
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
||||
class TestExternalTablesView(BaseTestGenerator):
|
||||
class TestProperties(BaseTestGenerator):
|
||||
scenarios = [
|
||||
('#properties When retrieving the properties of a external table '
|
||||
'and the table exists, '
|
||||
|
@ -27,9 +27,7 @@ class TestTemplateCreate(BaseTestGenerator):
|
||||
'when no primary key is present, '
|
||||
'it returns "DISTRIBUTED RANDOMLY"',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'table', 'sql', 'gpdb_5.0_plus', 'create.sql'
|
||||
),
|
||||
template_path='table/sql/gpdb_5.0_plus/create.sql',
|
||||
input_parameters=dict(
|
||||
data=dict()
|
||||
),
|
||||
@ -43,8 +41,7 @@ class TestTemplateCreate(BaseTestGenerator):
|
||||
'when primary key is present, '
|
||||
'it returns "DISTRIBUTED BY (attr_primary_key)"',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'table', 'sql', 'gpdb_5.0_plus', 'create.sql'),
|
||||
template_path='table/sql/gpdb_5.0_plus/create.sql',
|
||||
input_parameters=dict(
|
||||
data=dict(
|
||||
primary_key=[
|
||||
@ -69,8 +66,7 @@ class TestTemplateCreate(BaseTestGenerator):
|
||||
'when distribution is present, '
|
||||
'it returns "DISTRIBUTED BY (attr1, attr2, attr4)"',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'table', 'sql', 'gpdb_5.0_plus', 'create.sql'),
|
||||
template_path='table/sql/gpdb_5.0_plus/create.sql',
|
||||
input_parameters=dict(
|
||||
data=dict(
|
||||
distribution=[1, 2, 4],
|
||||
|
@ -61,16 +61,14 @@ DATABASE_ID = 123
|
||||
_ = MagicMock(side_effect=lambda x: x)
|
||||
|
||||
|
||||
class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
class TestDashboardTemplates(BaseTestGenerator):
|
||||
scenarios = [
|
||||
# Server dashboard
|
||||
(
|
||||
'Dashboard, when returning the html page with graphs and '
|
||||
'server activity related html elements for server dashboard',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'dashboard', 'server_dashboard.html'
|
||||
),
|
||||
template_path='dashboard/server_dashboard.html',
|
||||
input_parameters=dict(
|
||||
sid=SERVER_ID,
|
||||
did=None,
|
||||
@ -90,9 +88,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'Dashboard, when returning the html page with only graphs '
|
||||
'related html elements for server dashboard',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'dashboard', 'server_dashboard.html'
|
||||
),
|
||||
template_path='dashboard/server_dashboard.html',
|
||||
input_parameters=dict(
|
||||
sid=SERVER_ID,
|
||||
did=None,
|
||||
@ -113,9 +109,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'Dashboard, when returning the html page with only server '
|
||||
'activity related html elements for server dashboard',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'dashboard', 'server_dashboard.html'
|
||||
),
|
||||
template_path='dashboard/server_dashboard.html',
|
||||
input_parameters=dict(
|
||||
sid=SERVER_ID,
|
||||
did=None,
|
||||
@ -137,9 +131,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'graphs nor server activity related html elements for server '
|
||||
'dashboard',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'dashboard', 'server_dashboard.html'
|
||||
),
|
||||
template_path='dashboard/server_dashboard.html',
|
||||
input_parameters=dict(
|
||||
sid=SERVER_ID,
|
||||
did=None,
|
||||
@ -160,9 +152,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'Dashboard, when returning the html page with graphs and '
|
||||
'database activity related html elements for database dashboard',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'dashboard', 'database_dashboard.html'
|
||||
),
|
||||
template_path='dashboard/database_dashboard.html',
|
||||
input_parameters=dict(
|
||||
sid=SERVER_ID,
|
||||
did=DATABASE_ID,
|
||||
@ -182,9 +172,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'Dashboard, when returning the html page with only '
|
||||
'graphs related html elements for database dashboard',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'dashboard', 'database_dashboard.html'
|
||||
),
|
||||
template_path='dashboard/database_dashboard.html',
|
||||
input_parameters=dict(
|
||||
sid=SERVER_ID,
|
||||
did=DATABASE_ID,
|
||||
@ -205,9 +193,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'Dashboard, when returning the html page with only '
|
||||
'database activity related html elements for database dashboard',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'dashboard', 'database_dashboard.html'
|
||||
),
|
||||
template_path='dashboard/database_dashboard.html',
|
||||
input_parameters=dict(
|
||||
sid=SERVER_ID,
|
||||
did=DATABASE_ID,
|
||||
@ -229,9 +215,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'graphs nor database activity related html elements for database '
|
||||
'dashboard',
|
||||
dict(
|
||||
template_path=os.path.join(
|
||||
'dashboard', 'database_dashboard.html'
|
||||
),
|
||||
template_path='dashboard/database_dashboard.html',
|
||||
input_parameters=dict(
|
||||
sid=SERVER_ID,
|
||||
did=DATABASE_ID,
|
||||
|
@ -23,8 +23,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'when passing all parameters,'
|
||||
'it returns the explain plan with all parameters',
|
||||
dict(
|
||||
template_path=os.path.join('sqleditor', 'sql', 'default',
|
||||
'explain_plan.sql'),
|
||||
template_path='sqleditor/sql/default/explain_plan.sql',
|
||||
input_parameters=dict(
|
||||
sql='SELECT * FROM places',
|
||||
format='xml',
|
||||
@ -45,8 +44,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'when not all parameters are present,'
|
||||
'it returns the explain plan with the present parameters',
|
||||
dict(
|
||||
template_path=os.path.join('sqleditor', 'sql', 'default',
|
||||
'explain_plan.sql'),
|
||||
template_path='sqleditor/sql/default/explain_plan.sql',
|
||||
input_parameters=dict(
|
||||
sql='SELECT * FROM places',
|
||||
format='json',
|
||||
@ -63,8 +61,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'when timing is present,'
|
||||
'it returns the explain plan with timing',
|
||||
dict(
|
||||
template_path=os.path.join('sqleditor', 'sql', '9.2_plus',
|
||||
'explain_plan.sql'),
|
||||
template_path='sqleditor/sql/9.2_plus/explain_plan.sql',
|
||||
input_parameters=dict(
|
||||
sql='SELECT * FROM places',
|
||||
format='json',
|
||||
@ -82,8 +79,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'when summary is present,'
|
||||
'it returns the explain plan with summary',
|
||||
dict(
|
||||
template_path=os.path.join('sqleditor', 'sql', '10_plus',
|
||||
'explain_plan.sql'),
|
||||
template_path='sqleditor/sql/10_plus/explain_plan.sql',
|
||||
input_parameters=dict(
|
||||
sql='SELECT * FROM places',
|
||||
format='yaml',
|
||||
@ -103,8 +99,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'when all parameters are present,'
|
||||
'it returns the explain without parameters',
|
||||
dict(
|
||||
template_path=os.path.join('sqleditor', 'sql', 'gpdb_5.0_plus',
|
||||
'explain_plan.sql'),
|
||||
template_path='sqleditor/sql/gpdb_5.0_plus/explain_plan.sql',
|
||||
input_parameters=dict(
|
||||
sql='SELECT * FROM places',
|
||||
format='json',
|
||||
@ -119,8 +114,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'when analyze is true,'
|
||||
'it returns the explain analyze',
|
||||
dict(
|
||||
template_path=os.path.join('sqleditor', 'sql', 'gpdb_5.0_plus',
|
||||
'explain_plan.sql'),
|
||||
template_path='sqleditor/sql/gpdb_5.0_plus/explain_plan.sql',
|
||||
input_parameters=dict(
|
||||
sql='SELECT * FROM places',
|
||||
analyze=True
|
||||
@ -134,8 +128,7 @@ class TestExplainPlanTemplates(BaseTestGenerator):
|
||||
'when analyze is false,'
|
||||
'it returns the only explain',
|
||||
dict(
|
||||
template_path=os.path.join('sqleditor', 'sql', 'gpdb_5.0_plus',
|
||||
'explain_plan.sql'),
|
||||
template_path='sqleditor/sql/gpdb_5.0_plus/explain_plan.sql',
|
||||
input_parameters=dict(
|
||||
sql='SELECT * FROM places',
|
||||
analyze=False
|
||||
|
@ -35,10 +35,7 @@ class TestViewDataTemplates(BaseTestGenerator):
|
||||
(
|
||||
'When inserting and selecting table data with only PK',
|
||||
dict(
|
||||
insert_template_path=os.path.join('sqleditor',
|
||||
'sql',
|
||||
'default',
|
||||
'insert.sql'),
|
||||
insert_template_path='sqleditor/sql/default/insert.sql',
|
||||
insert_parameters=dict(
|
||||
data_to_be_saved=data_to_be_saved,
|
||||
primary_keys=None,
|
||||
@ -54,10 +51,7 @@ class TestViewDataTemplates(BaseTestGenerator):
|
||||
' (%(id)s::integer, '
|
||||
'%(text)s::text)'
|
||||
' returning id;',
|
||||
select_template_path=os.path.join('sqleditor',
|
||||
'sql',
|
||||
'default',
|
||||
'select.sql'),
|
||||
select_template_path='sqleditor/sql/default/select.sql',
|
||||
select_parameters=dict(
|
||||
object_name='test_table',
|
||||
nsp_name='test_schema',
|
||||
@ -71,10 +65,7 @@ class TestViewDataTemplates(BaseTestGenerator):
|
||||
(
|
||||
'When inserting and selecting table data with multiple PK',
|
||||
dict(
|
||||
insert_template_path=os.path.join('sqleditor',
|
||||
'sql',
|
||||
'default',
|
||||
'insert.sql'),
|
||||
insert_template_path='sqleditor/sql/default/insert.sql',
|
||||
insert_parameters=dict(
|
||||
data_to_be_saved=data_to_be_saved,
|
||||
primary_keys=None,
|
||||
@ -90,10 +81,7 @@ class TestViewDataTemplates(BaseTestGenerator):
|
||||
' VALUES (%(id)s::integer,'
|
||||
' %(text)s::text)'
|
||||
' returning id, text;',
|
||||
select_template_path=os.path.join('sqleditor',
|
||||
'sql',
|
||||
'default',
|
||||
'select.sql'),
|
||||
select_template_path='sqleditor/sql/default/select.sql',
|
||||
select_parameters=dict(
|
||||
object_name='test_table',
|
||||
nsp_name='test_schema',
|
||||
@ -109,10 +97,7 @@ class TestViewDataTemplates(BaseTestGenerator):
|
||||
(
|
||||
'When inserting and selecting table data with PK and OID',
|
||||
dict(
|
||||
insert_template_path=os.path.join('sqleditor',
|
||||
'sql',
|
||||
'default',
|
||||
'insert.sql'),
|
||||
insert_template_path='sqleditor/sql/default/insert.sql',
|
||||
insert_parameters=dict(
|
||||
data_to_be_saved=data_to_be_saved,
|
||||
primary_keys=None,
|
||||
@ -128,10 +113,7 @@ class TestViewDataTemplates(BaseTestGenerator):
|
||||
' (%(id)s::integer, '
|
||||
'%(text)s::text) '
|
||||
'returning oid;',
|
||||
select_template_path=os.path.join('sqleditor',
|
||||
'sql',
|
||||
'default',
|
||||
'select.sql'),
|
||||
select_template_path='sqleditor/sql/default/select.sql',
|
||||
select_parameters=dict(
|
||||
object_name='test_table',
|
||||
nsp_name='test_schema',
|
||||
@ -145,10 +127,7 @@ class TestViewDataTemplates(BaseTestGenerator):
|
||||
(
|
||||
'When inserting and selecting table data with only OID',
|
||||
dict(
|
||||
insert_template_path=os.path.join('sqleditor',
|
||||
'sql',
|
||||
'default',
|
||||
'insert.sql'),
|
||||
insert_template_path='sqleditor/sql/default/insert.sql',
|
||||
insert_parameters=dict(
|
||||
data_to_be_saved=data_to_be_saved,
|
||||
primary_keys=None,
|
||||
@ -164,10 +143,7 @@ class TestViewDataTemplates(BaseTestGenerator):
|
||||
' (%(id)s::integer,'
|
||||
' %(text)s::text)'
|
||||
' returning oid;',
|
||||
select_template_path=os.path.join('sqleditor',
|
||||
'sql',
|
||||
'default',
|
||||
'select.sql'),
|
||||
select_template_path='sqleditor/sql/default/select.sql',
|
||||
select_parameters=dict(
|
||||
object_name='test_table',
|
||||
nsp_name='test_schema',
|
||||
|
Loading…
Reference in New Issue
Block a user