@@ -385,7 +385,6 @@ def test_create_local_unit_administrative(self):
385385 "type" : type .id ,
386386 "country" : country .id ,
387387 "draft" : False ,
388- "validated" : True ,
389388 "postcode" : "4407" ,
390389 "address_loc" : "4407" ,
391390 "address_en" : "" ,
@@ -416,6 +415,7 @@ def test_create_local_unit_administrative(self):
416415 data ["english_branch_name" ] = "Test branch name"
417416 response = self .client .post ("/api/v2/local-units/" , data = data , format = "json" )
418417 self .assertEqual (response .status_code , 201 )
418+ self .assertEqual (response .data ["status" ], LocalUnit .Status .UNVALIDATED )
419419
420420 # Checking the request changes for the local unit is created or not
421421 request_change = LocalUnitChangeRequest .objects .all ()
@@ -438,7 +438,6 @@ def test_create_update_local_unit_health(self):
438438 "created_at" : "2024-05-13T06:53:14.978083Z" ,
439439 "modified_at" : "2024-05-13T06:53:14.978099Z" ,
440440 "draft" : False ,
441- "validated" : True ,
442441 "postcode" : "" ,
443442 "address_loc" : "Silele Clinic is is in Hosea Inkhundla under the Shiselweni, Sigombeni is in Nkom'iyahlaba Inkhundla under the Manzini region and Mahwalala is in the Mbabane West Inkhundla under the Hhohho region." , # noqa: E501
444443 "address_en" : "" ,
@@ -506,6 +505,7 @@ def test_create_update_local_unit_health(self):
506505 self .assertEqual (response .status_code , 201 )
507506 self .assertEqual (LocalUnitChangeRequest .objects .count (), 1 )
508507 self .assertEqual (response .data ["is_locked" ], True )
508+ self .assertEqual (response .data ["status" ], LocalUnit .Status .UNVALIDATED )
509509 # Locked local unit should not be updated, until it is unlocked
510510 local_unit_id = response .data ["id" ]
511511 response = self .client .put (f"/api/v2/local-units/{ local_unit_id } /" , data = data , format = "json" )
@@ -529,7 +529,6 @@ def test_revert_local_unit(self):
529529 "created_at" : "2024-05-13T06:53:14.978083Z" ,
530530 "modified_at" : "2024-05-13T06:53:14.978099Z" ,
531531 "draft" : False ,
532- "validated" : True ,
533532 "postcode" : "" ,
534533 "address_loc" : "Silele Clinic is is in Hosea Inkhundla under the Shiselweni, Sigombeni is in Nkom'iyahlaba Inkhundla under the Manzini region and Mahwalala is in the Mbabane West Inkhundla under the Hhohho region." , # noqa: E501
535534 "address_en" : "" ,
@@ -579,8 +578,8 @@ def test_revert_local_unit(self):
579578 response = self .client .post (f"/api/v2/local-units/{ local_unit_id } /validate/" )
580579 self .assert_200 (response )
581580 self .assertEqual (response .data ["is_locked" ], False )
582- self .assertEqual (response .data ["validated" ], True )
583-
581+ # self.assertEqual(response.data["validated"], True)
582+ self . assertEqual ( response . data [ "status" ], LocalUnit . Status . VALIDATED )
584583 # saving the previous data
585584 previous_data = response .data
586585
@@ -591,7 +590,6 @@ def test_revert_local_unit(self):
591590 response = self .client .put (f"/api/v2/local-units/{ local_unit_id } /" , data = data , format = "json" )
592591 self .assert_200 (response )
593592 self .assertEqual (response .data ["local_branch_name" ], data ["local_branch_name" ])
594-
595593 # Reverting the local unit
596594 revert_data = {
597595 "reason" : "Reverting the local unit test" ,
@@ -609,7 +607,7 @@ def test_revert_local_unit(self):
609607 self .assertEqual (local_unit_change_request .rejected_reason , revert_data ["reason" ])
610608 # Checking if the local unit is unlocked
611609 self .assertEqual (local_unit .is_locked , False )
612- self .assertEqual (local_unit .validated , True )
610+ self .assertEqual (local_unit .status , LocalUnit . Status . VALIDATED )
613611
614612 def test_latest_changes (self ):
615613 region = Region .objects .create (name = 2 )
@@ -627,7 +625,7 @@ def test_latest_changes(self):
627625 "country" : country .id ,
628626 "created_at" : "2024-05-13T06:53:14.978083Z" ,
629627 "modified_at" : "2024-05-13T06:53:14.978099Z" ,
630- "validated " : True ,
628+ "status " : LocalUnit . Status . VALIDATED ,
631629 "date_of_data" : "2024-05-13" ,
632630 "level" : level .id ,
633631 "address_loc" : "Silele Clinic is is in Hosea Inkhundla under the Shiselweni, Sigombeni is in Nkom'iyahlaba Inkhundla under the Manzini region and Mahwalala is in the Mbabane West Inkhundla under the Hhohho region." , # noqa: E501
@@ -687,7 +685,7 @@ def test_validate_local_unit(self):
687685 self .authenticate ()
688686 response = self .client .post ("/api/v2/local-units/" , data = data , format = "json" )
689687 self .assert_201 (response )
690-
688+ self . assertEqual ( response . data [ "status" ], LocalUnit . Status . UNVALIDATED )
691689 local_unit_id = response .data ["id" ]
692690 self .authenticate (self .global_validator_user )
693691 # validating the local unit by the Global validator
@@ -697,6 +695,7 @@ def test_validate_local_unit(self):
697695 local_unit = local_unit_id , status = LocalUnitChangeRequest .Status .APPROVED
698696 ).last ()
699697 self .assertEqual (local_unit_request .current_validator , Validator .GLOBAL )
698+ self .assertEqual (response .data ["status" ], LocalUnit .Status .VALIDATED )
700699
701700 # Testing For the local unit admin/country validator
702701 self .authenticate (self .country_validator_user )
@@ -709,6 +708,7 @@ def test_validate_local_unit(self):
709708 local_unit = local_unit_id , status = LocalUnitChangeRequest .Status .APPROVED
710709 ).last ()
711710 self .assertEqual (local_unit_request .current_validator , Validator .LOCAL )
711+ self .assertEqual (response .data ["status" ], LocalUnit .Status .VALIDATED )
712712
713713 # Testing For the regional validator
714714 self .authenticate (self .region_validator_user )
@@ -720,6 +720,7 @@ def test_validate_local_unit(self):
720720 local_unit = local_unit_id , status = LocalUnitChangeRequest .Status .APPROVED
721721 ).last ()
722722 self .assertEqual (local_unit_request .current_validator , Validator .REGIONAL )
723+ self .assertEqual (response .data ["status" ], LocalUnit .Status .VALIDATED )
723724
724725 # Testing for Root User/Global validator
725726 self .authenticate (self .root_user )
@@ -731,6 +732,7 @@ def test_validate_local_unit(self):
731732 local_unit = local_unit_id , status = LocalUnitChangeRequest .Status .APPROVED
732733 ).last ()
733734 self .assertEqual (local_unit_request .current_validator , Validator .GLOBAL )
735+ self .assertEqual (response .data ["status" ], LocalUnit .Status .VALIDATED )
734736
735737
736738class TestExternallyManagedLocalUnit (APITestCase ):
0 commit comments