Skip to content

Commit 61e81b6

Browse files
committed
Construct a more descriptive test name for not null constraints which have system generated (SYS_) based names.
1 parent 890fb7b commit 61e81b6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/model/utplsql_generator.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
__date__ = "2024-11-09"
55
__description__ = "Generates the utPLSQL test skeleton code - package spec & package body."
66

7+
import copy
8+
79
from lib.file_system_utils import project_home
810
from lib.config_mgr import ConfigManager
911
from model.db_objects import Table
@@ -21,7 +23,7 @@
2123

2224

2325
# Define our substitution placeholder string for indent spaces.
24-
# The number of spaces for an indent tab, is defined in OraTAPI.ini
26+
# The number of spaces for an indent tab is defined in OraTAPI.ini
2527
IDNT = '%indent_spaces%'
2628

2729
APP_HOME = project_home()
@@ -389,6 +391,9 @@ def gen_package_body(self) -> str:
389391

390392
_procedure_name = constraint_dict["constraint_name_lc"]
391393
constraint_type = constraint_dict["constraint_type"]
394+
if 'sys_' in _procedure_name and constraint_type == 'N':
395+
_procedure_name = f"{cons_columns[0].lower()}_not_null"
396+
392397
merged_dict["throws_code"] = self.constraint_exceptions_map[constraint_type]
393398

394399

@@ -519,6 +524,8 @@ def gen_package_spec(self) -> str:
519524

520525
_procedure_name = constraint_dict["constraint_name_lc"]
521526
constraint_type = constraint_dict["constraint_type"]
527+
if 'sys_' in _procedure_name and constraint_type == 'N':
528+
_procedure_name = f"{cons_columns[0].lower()}_not_null"
522529

523530
merged_dict["throws_code"] = self.constraint_exceptions_map[constraint_type]
524531

@@ -560,8 +567,11 @@ def _construct_constraint_test(self, procedure_basename: str, procedure_name: st
560567

561568
procedure = self._package_api_template(template_category="ut_packages", template_type=template_type,
562569
template_name='constraint_test')
570+
_constraint_dict = copy.deepcopy(constraint_dict)
563571

564-
subst_dict = {"api_type": procedure_basename, "procedure_name": procedure_name} | constraint_dict
572+
_constraint_dict["constraint_name"] = procedure_name.upper()
573+
_constraint_dict["constraint_name_lc"] = procedure_name.lower()
574+
subst_dict = {"api_type": procedure_basename, "procedure_name": procedure_name} | _constraint_dict
565575

566576

567577
procedure = inject_values(substitutions=subst_dict,

0 commit comments

Comments
 (0)