1) Fixed Schema Diff issue.

2) Remove unsupported versions from the get_version_mapping_directories() function.
3) Updated test cases for version template loader.
This commit is contained in:
Akshay Joshi 2023-06-19 18:44:55 +05:30
parent c5cbb33a06
commit 5d619fd455
9 changed files with 37 additions and 48 deletions

View File

@ -37,5 +37,6 @@ Bug fixes
| `Issue #6291 <https://github.com/pgadmin-org/pgadmin4/issues/6291>`_ - Fix an issue where loading more rows indicator will not disappear if connection is lost.
| `Issue #6340 <https://github.com/pgadmin-org/pgadmin4/issues/6340>`_ - Fix an encoding error when connecting through Pgbouncer.
| `Issue #6363 <https://github.com/pgadmin-org/pgadmin4/issues/6363>`_ - Fixed an issue where preview images for themes were not loading.
| `Issue #6420 <https://github.com/pgadmin-org/pgadmin4/issues/6420>`_ - Fix raise notice from func/proc or code blocks are no longer displayed live.
| `Issue #6431 <https://github.com/pgadmin-org/pgadmin4/issues/6431>`_ - Fix an issue where PSQL is not working if the database name have quotes or double quotes.

View File

@ -562,9 +562,6 @@ def compare_database(params):
comparison_result = \
comparison_result + comparison_schema_result
msg = gettext("Successfully compare the specified databases.")
total_percent = 100
diff_model_obj.set_comparison_info(msg, total_percent)
# Update the message and total percentage done in session object
update_session_diff_transaction(params['trans_id'], session_obj,
diff_model_obj)
@ -625,9 +622,6 @@ def compare_schema(params):
comparison_result = \
comparison_result + comparison_schema_result
msg = gettext("Successfully compare the specified schemas.")
total_percent = 100
diff_model_obj.set_comparison_info(msg, total_percent)
# Update the message and total percentage done in session object
update_session_diff_transaction(params['trans_id'], session_obj,
diff_model_obj)

View File

@ -0,0 +1 @@
Some 12 SQL

View File

@ -16,6 +16,8 @@ from jinja2 import TemplateNotFound
from pgadmin import VersionedTemplateLoader
from pgadmin.utils.route import BaseTestGenerator
TEST_FILE_NAME = "some_action.sql"
class TestVersionedTemplateLoader(BaseTestGenerator):
scenarios = [
@ -24,16 +26,16 @@ class TestVersionedTemplateLoader(BaseTestGenerator):
dict(scenario=1)
),
(
"Render a version 9.1 template when it is present",
"Render a version 11 template when it is present",
dict(scenario=2)
),
(
"Render a version 9.2 template when request for a higher version",
"Render a version 12 template when request for a higher version",
dict(scenario=3)
),
(
"Render default version when version 9.0 was requested and only "
"9.1 and 9.2 are present",
"Render default version when version 10 was requested and only "
"11 and 12 are present",
dict(scenario=4)
),
(
@ -49,16 +51,16 @@ class TestVersionedTemplateLoader(BaseTestGenerator):
if self.scenario == 1:
self.test_get_source_returns_a_template()
if self.scenario == 2:
# test_get_source_when_the_version_is_9_1_returns_9_1_template
self.test_get_source_when_the_version_is_9_1()
# test_get_source_when_the_version_is_11_returns_11_template
self.test_get_source_when_the_version_is_11()
if self.scenario == 3:
# test_get_source_when_the_version_is_9_3_and_there_are_templates_
# for_9_2_and_9_1_returns_9_2_template
self.test_get_source_when_the_version_is_9_3()
# test_get_source_when_the_version_is_13_and_there_are_templates_
# for_12_and_11_returns_12_template
self.test_get_source_when_the_version_is_13()
if self.scenario == 4:
# test_get_source_when_the_version_is_9_0_and_there_are_templates_
# for_9_1_and_9_2_returns_default_template
self.test_get_source_when_the_version_is_9_0()
# test_get_source_when_the_version_is_10_and_there_are_templates_
# for_11_and_12_returns_default_template
self.test_get_source_when_the_version_is_10()
if self.scenario == 5:
# test_raise_not_found_exception_when_postgres_version_less_than_
# all_available_sql_templates
@ -67,30 +69,30 @@ class TestVersionedTemplateLoader(BaseTestGenerator):
def test_get_source_returns_a_template(self):
expected_content = "Some SQL" \
"\nsome more stuff on a new line\n"
# For cross platform we join the SQL path
# For cross-platform we join the SQL path
# (This solves the slashes issue)
sql_path = os.path.join(
"some_feature", "sql", "9.1_plus", "some_action.sql"
"some_feature", "sql", "11_plus", TEST_FILE_NAME
)
content, filename, up_to_dateness = self.loader.get_source(
None, "some_feature/sql/9.1_plus/some_action.sql"
None, "some_feature/sql/11_plus/some_action.sql"
)
self.assertEqual(
expected_content, str(content).replace("\r", "")
)
self.assertIn(sql_path, filename)
def test_get_source_when_the_version_is_9_1(self):
"""Render a version 9.1 template when it is present"""
def test_get_source_when_the_version_is_11(self):
"""Render a version 11 template when it is present"""
expected_content = "Some SQL" \
"\nsome more stuff on a new line\n"
# For cross platform we join the SQL path
# For cross-platform we join the SQL path
# (This solves the slashes issue)
sql_path = os.path.join(
"some_feature", "sql", "9.1_plus", "some_action.sql"
"some_feature", "sql", "11_plus", TEST_FILE_NAME
)
content, filename, up_to_dateness = self.loader.get_source(
None, "some_feature/sql/#90100#/some_action.sql"
None, "some_feature/sql/#110000#/some_action.sql"
)
self.assertEqual(
@ -98,33 +100,33 @@ class TestVersionedTemplateLoader(BaseTestGenerator):
)
self.assertIn(sql_path, filename)
def test_get_source_when_the_version_is_9_3(self):
"""Render a version 9.2 template when request for a higher version"""
# For cross platform we join the SQL path
def test_get_source_when_the_version_is_13(self):
"""Render a version 12 template when request for a higher version"""
# For cross-platform we join the SQL path
# (This solves the slashes issue)
sql_path = os.path.join(
"some_feature", "sql", "9.2_plus", "some_action.sql"
"some_feature", "sql", "12_plus", TEST_FILE_NAME
)
content, filename, up_to_dateness = self.loader.get_source(
None, "some_feature/sql/#90300#/some_action.sql"
None, "some_feature/sql/#130000#/some_action.sql"
)
self.assertEqual(
"Some 9.2 SQL", str(content).replace("\r", "")
"Some 12 SQL\n", str(content).replace("\r", "")
)
self.assertIn(sql_path, filename)
def test_get_source_when_the_version_is_9_0(self):
"""Render default version when version 9.0 was requested and only
9.1 and 9.2 are present"""
def test_get_source_when_the_version_is_10(self):
"""Render default version when version 10 was requested and only
11 and 12 are present"""
# For cross platform we join the SQL path
# For cross-platform we join the SQL path
# (This solves the slashes issue)
sql_path = os.path.join("some_feature", "sql",
"default", "some_action_with_default.sql")
content, filename, up_to_dateness = self.loader.get_source(
None,
"some_feature/sql/#90000#/some_action_with_default.sql")
"some_feature/sql/#100000#/some_action_with_default.sql")
self.assertEqual("Some default SQL", str(content).replace("\r", ""))
self.assertIn(sql_path, filename)

View File

@ -81,12 +81,4 @@ def get_version_mapping_directories():
{'name': "13_plus", 'number': 130000},
{'name': "12_plus", 'number': 120000},
{'name': "11_plus", 'number': 110000},
{'name': "10_plus", 'number': 100000},
{'name': "9.6_plus", 'number': 90600},
{'name': "9.5_plus", 'number': 90500},
{'name': "9.4_plus", 'number': 90400},
{'name': "9.3_plus", 'number': 90300},
{'name': "9.2_plus", 'number': 90200},
{'name': "9.1_plus", 'number': 90100},
{'name': "9.0_plus", 'number': 90000},
{'name': "default", 'number': 0})