Skip to content

Commit 8e191b1

Browse files
committed
fixes the unit tests for new changes
1 parent 00a36c1 commit 8e191b1

File tree

2 files changed

+89
-107
lines changed

2 files changed

+89
-107
lines changed

lib/idp_common_pkg/idp_common/bda/bda_blueprint_service.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ def _retrieve_all_blueprints(self, project_arn: str):
146146
return []
147147

148148
def _check_for_updates(self, custom_class: dict, blueprint: dict):
149-
# blueprint = self.blueprint_creator.get_blueprint(blueprint_arn, stage="LIVE")
150-
# print(f"blueprint retrieved {blueprint}")
151149
# get the schema
152150
schema = blueprint["schema"]
153151
schema = json.loads(schema)

lib/idp_common_pkg/tests/unit/bda/test_bda_blueprint_service.py

Lines changed: 89 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -437,28 +437,26 @@ def test_check_for_updates_no_changes(self, service):
437437

438438
# Mock existing blueprint schema that matches the custom class
439439
existing_blueprint = {
440-
"blueprint": {
441-
"schema": json.dumps(
442-
{
443-
"class": "W-4",
444-
"description": "Employee's Withholding Certificate form",
445-
"definitions": {
446-
"Personalinformation": { # Formatted section name (capitalize)
447-
"properties": {
448-
"firstname": { # Formatted field name (lowercase)
449-
"type": "string",
450-
"instruction": "First Name of Employee",
451-
},
452-
"lastname": { # Formatted field name (lowercase)
453-
"type": "string",
454-
"instruction": "Last Name of Employee",
455-
},
456-
}
440+
"schema": json.dumps(
441+
{
442+
"class": "W-4",
443+
"description": "Employee's Withholding Certificate form",
444+
"definitions": {
445+
"Personalinformation": { # Formatted section name (capitalize)
446+
"properties": {
447+
"firstname": { # Formatted field name (lowercase)
448+
"type": "string",
449+
"instruction": "First Name of Employee",
450+
},
451+
"lastname": { # Formatted field name (lowercase)
452+
"type": "string",
453+
"instruction": "Last Name of Employee",
454+
},
457455
}
458-
},
459-
}
460-
)
461-
}
456+
}
457+
},
458+
}
459+
)
462460
}
463461

464462
# Execute the method
@@ -476,15 +474,13 @@ def test_check_for_updates_class_name_changed(self, service):
476474
}
477475

478476
existing_blueprint = {
479-
"blueprint": {
480-
"schema": json.dumps(
481-
{
482-
"class": "W-4", # Original name
483-
"description": "Employee's Withholding Certificate form",
484-
"definitions": {},
485-
}
486-
)
487-
}
477+
"schema": json.dumps(
478+
{
479+
"class": "W-4", # Original name
480+
"description": "Employee's Withholding Certificate form",
481+
"definitions": {},
482+
}
483+
)
488484
}
489485

490486
result = service._check_for_updates(custom_class, existing_blueprint)
@@ -501,15 +497,13 @@ def test_check_for_updates_description_changed(self, service):
501497
}
502498

503499
existing_blueprint = {
504-
"blueprint": {
505-
"schema": json.dumps(
506-
{
507-
"class": "W-4",
508-
"description": "Employee's Withholding Certificate form", # Original description
509-
"definitions": {},
510-
}
511-
)
512-
}
500+
"schema": json.dumps(
501+
{
502+
"class": "W-4",
503+
"description": "Employee's Withholding Certificate form", # Original description
504+
"definitions": {},
505+
}
506+
)
513507
}
514508

515509
result = service._check_for_updates(custom_class, existing_blueprint)
@@ -532,20 +526,18 @@ def test_check_for_updates_new_group_added(self, service):
532526
}
533527

534528
existing_blueprint = {
535-
"blueprint": {
536-
"schema": json.dumps(
537-
{
538-
"class": "W-4",
539-
"description": "Employee's Withholding Certificate form",
540-
"definitions": {
541-
"Personalinformation": { # Formatted section name (capitalize)
542-
"properties": {}
543-
}
544-
# Newsection is missing
545-
},
546-
}
547-
)
548-
}
529+
"schema": json.dumps(
530+
{
531+
"class": "W-4",
532+
"description": "Employee's Withholding Certificate form",
533+
"definitions": {
534+
"Personalinformation": { # Formatted section name (capitalize)
535+
"properties": {}
536+
}
537+
# Newsection is missing
538+
},
539+
}
540+
)
549541
}
550542

551543
result = service._check_for_updates(custom_class, existing_blueprint)
@@ -573,24 +565,22 @@ def test_check_for_updates_field_description_changed(self, service):
573565
}
574566

575567
existing_blueprint = {
576-
"blueprint": {
577-
"schema": json.dumps(
578-
{
579-
"class": "W-4",
580-
"description": "Employee's Withholding Certificate form",
581-
"definitions": {
582-
"Personalinformation": { # Formatted section name (capitalize)
583-
"properties": {
584-
"firstname": { # Formatted field name (lowercase)
585-
"type": "string",
586-
"instruction": "First Name of Employee", # Original description
587-
}
568+
"schema": json.dumps(
569+
{
570+
"class": "W-4",
571+
"description": "Employee's Withholding Certificate form",
572+
"definitions": {
573+
"Personalinformation": { # Formatted section name (capitalize)
574+
"properties": {
575+
"firstname": { # Formatted field name (lowercase)
576+
"type": "string",
577+
"instruction": "First Name of Employee", # Original description
588578
}
589579
}
590-
},
591-
}
592-
)
593-
}
580+
}
581+
},
582+
}
583+
)
594584
}
595585

596586
result = service._check_for_updates(custom_class, existing_blueprint)
@@ -623,25 +613,23 @@ def test_check_for_updates_new_field_added(self, service):
623613
}
624614

625615
existing_blueprint = {
626-
"blueprint": {
627-
"schema": json.dumps(
628-
{
629-
"class": "W-4",
630-
"description": "Employee's Withholding Certificate form",
631-
"definitions": {
632-
"Personalinformation": { # Formatted section name (capitalize)
633-
"properties": {
634-
"firstname": { # Formatted field name (lowercase)
635-
"type": "string",
636-
"instruction": "First Name of Employee",
637-
}
638-
# middlename is missing
616+
"schema": json.dumps(
617+
{
618+
"class": "W-4",
619+
"description": "Employee's Withholding Certificate form",
620+
"definitions": {
621+
"Personalinformation": { # Formatted section name (capitalize)
622+
"properties": {
623+
"firstname": { # Formatted field name (lowercase)
624+
"type": "string",
625+
"instruction": "First Name of Employee",
639626
}
627+
# middlename is missing
640628
}
641-
},
642-
}
643-
)
644-
}
629+
}
630+
},
631+
}
632+
)
645633
}
646634

647635
result = service._check_for_updates(custom_class, existing_blueprint)
@@ -658,7 +646,7 @@ def test_check_for_updates_blueprint_retrieval_error(self, service):
658646
}
659647

660648
# Invalid blueprint with malformed schema
661-
invalid_blueprint = {"blueprint": {"schema": "invalid json"}}
649+
invalid_blueprint = {"schema": "invalid json"}
662650

663651
# Should raise the exception
664652
with pytest.raises(json.JSONDecodeError):
@@ -673,15 +661,13 @@ def test_check_for_updates_empty_attributes(self, service):
673661
}
674662

675663
existing_blueprint = {
676-
"blueprint": {
677-
"schema": json.dumps(
678-
{
679-
"class": "W-4",
680-
"description": "Employee's Withholding Certificate form",
681-
"definitions": {},
682-
}
683-
)
684-
}
664+
"schema": json.dumps(
665+
{
666+
"class": "W-4",
667+
"description": "Employee's Withholding Certificate form",
668+
"definitions": {},
669+
}
670+
)
685671
}
686672

687673
result = service._check_for_updates(custom_class, existing_blueprint)
@@ -698,15 +684,13 @@ def test_check_for_updates_missing_attributes_key(self, service):
698684
}
699685

700686
existing_blueprint = {
701-
"blueprint": {
702-
"schema": json.dumps(
703-
{
704-
"class": "W-4",
705-
"description": "Employee's Withholding Certificate form",
706-
"definitions": {},
707-
}
708-
)
709-
}
687+
"schema": json.dumps(
688+
{
689+
"class": "W-4",
690+
"description": "Employee's Withholding Certificate form",
691+
"definitions": {},
692+
}
693+
)
710694
}
711695

712696
# Should handle missing attributes gracefully

0 commit comments

Comments
 (0)