pgadmin4/web/pgadmin/browser/tests/test_version_in_range.py

88 lines
2.5 KiB
Python
Raw Normal View History

##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
2023-01-02 00:23:55 -06:00
# Copyright (C) 2013 - 2023, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
from pgadmin.utils.route import BaseTestGenerator
from pgadmin.browser.utils import is_version_in_range
class VersionInRangeTestCase(BaseTestGenerator):
"""
This class validates the version in range functionality
by defining different version scenarios; where dict of
parameters describes the scenario appended by test name.
"""
scenarios = [
2018-03-07 05:47:01 -06:00
(
'TestCase for Validating pgversion 8.23 and min_version is 91000, '
2018-03-08 03:33:43 -06:00
'it should not show', dict(
2018-03-07 05:47:01 -06:00
sversion=82300,
min_version=90100,
max_version=1000000000,
scenario=2
2018-03-08 03:33:43 -06:00
)),
2018-03-07 05:47:01 -06:00
(
2018-03-08 03:33:43 -06:00
'TestCase for Validating pgversion 9.2, '
'it should show by default', dict(
2018-03-07 05:47:01 -06:00
sversion=90200,
min_version=0,
max_version=1000000000,
scenario=1
2018-03-08 03:33:43 -06:00
)),
2018-03-07 05:47:01 -06:00
(
'TestCase for Validating pgversion 9.2 and min/max are None, '
2018-03-08 03:33:43 -06:00
'it should show by default', dict(
2018-03-07 05:47:01 -06:00
sversion=90200,
min_version=None,
max_version=None,
scenario=1
2018-03-08 03:33:43 -06:00
)),
2018-03-07 05:47:01 -06:00
(
2018-03-08 03:33:43 -06:00
'TestCase for Validating pgversion 9.6 and max is lower, '
'it should not show', dict(
2018-03-07 05:47:01 -06:00
sversion=90600,
min_version=None,
max_version=90400,
scenario=2
2018-03-08 03:33:43 -06:00
))
]
@classmethod
def setUpClass(cls):
pass
2018-10-18 03:39:09 -05:00
# No need to call base class setup function
def setUp(self):
pass
def runTest(self):
"""This function will check version in range functionality."""
if self.scenario == 1:
self.test_result_is_true()
if self.scenario == 2:
self.test_result_is_false()
def test_result_is_true(self):
2018-03-07 05:47:01 -06:00
self.assertTrue(
is_version_in_range(
2018-03-08 03:33:43 -06:00
self.sversion,
self.min_version,
self.max_version
2018-03-07 05:47:01 -06:00
)
)
def test_result_is_false(self):
2018-03-07 05:47:01 -06:00
self.assertFalse(
is_version_in_range(
2018-03-08 03:33:43 -06:00
self.sversion,
self.min_version,
self.max_version
2018-03-07 05:47:01 -06:00
)
)