pgadmin4/web/pgadmin/utils/tests/test_compile_template_name.py

40 lines
1.3 KiB
Python
Raw Normal View History

#######################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
2019-01-02 04:24:12 -06:00
# Copyright (C) 2013 - 2019, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
from pgadmin.utils.compile_template_name import compile_template_name
from pgadmin.utils.route import BaseTestGenerator
class TestCompileTemplateName(BaseTestGenerator):
scenarios = [
2018-02-26 07:54:58 -06:00
(
'When server is Postgres and version is 10, it returns the path '
'to the postgres template',
dict(
server_type='pg',
version=100000,
expected_return_value='some/prefix/#100000#/some_file.sql'
)
),
(
'When server is GreenPlum and version is 5, it returns the path '
'to the GreenPlum template',
dict(
server_type='gpdb',
version=80323,
expected_return_value='some/prefix/#gpdb#80323#/some_file.sql'
)
),
]
def runTest(self):
2018-02-26 07:54:58 -06:00
result = compile_template_name(
'some/prefix', 'some_file.sql', self.server_type, self.version
)
self.assertEquals(result, self.expected_return_value)