TC-VALCC-4.2: unconditionally write open duration (#35852)

* TC-VALCC-4.2: unconditionally write open duration

This way we can ensure the open duration is writeable.
Also add a cleanup step.

* linter

* Update src/python_testing/TC_VALCC_4_2.py

Co-authored-by: fesseha-eve <88329315+fessehaeve@users.noreply.github.com>

* Update src/python_testing/TC_VALCC_4_2.py

Co-authored-by: fesseha-eve <88329315+fessehaeve@users.noreply.github.com>

---------

Co-authored-by: Andrei Litvin <andy314@gmail.com>
Co-authored-by: fesseha-eve <88329315+fessehaeve@users.noreply.github.com>
diff --git a/src/python_testing/TC_VALCC_4_2.py b/src/python_testing/TC_VALCC_4_2.py
index 7e331f5..1114f03 100644
--- a/src/python_testing/TC_VALCC_4_2.py
+++ b/src/python_testing/TC_VALCC_4_2.py
@@ -24,7 +24,6 @@
 # test-runner-run/run1/script-args: --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto
 # === END CI TEST ARGUMENTS ===
 
-import logging
 import time
 
 import chip.clusters as Clusters
@@ -55,6 +54,7 @@
             TestStep(8, "Send Close command"),
             TestStep(9, "Read OpenDuration attribute"),
             TestStep(10, "Read RemainingDuration attribute"),
+            TestStep(11, "Write DefaultOpenDuration back to original value")
         ]
         return steps
 
@@ -73,16 +73,11 @@
         attributes = Clusters.ValveConfigurationAndControl.Attributes
 
         self.step("2a")
-        defaultOpenDuration = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.DefaultOpenDuration)
+        originalDefaultOpenDuration = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.DefaultOpenDuration)
 
         self.step("2b")
-        if defaultOpenDuration is NullValue:
-            defaultOpenDuration = 60
-
-            result = await self.default_controller.WriteAttribute(self.dut_node_id, [(endpoint, attributes.DefaultOpenDuration(defaultOpenDuration))])
-            asserts.assert_equal(result[0].Status, Status.Success, "DefaultOpenDuration write failed")
-        else:
-            logging.info("Test step skipped")
+        defaultOpenDuration = 60
+        await self.write_single_attribute(attributes.DefaultOpenDuration(defaultOpenDuration), endpoint_id=endpoint)
 
         self.step(3)
         try:
@@ -129,6 +124,9 @@
         remaining_duration_dut = await self.read_valcc_attribute_expect_success(endpoint=endpoint, attribute=attributes.RemainingDuration)
         asserts.assert_true(remaining_duration_dut is NullValue, "RemainingDuration is not null")
 
+        self.step(11)
+        await self.write_single_attribute(attributes.DefaultOpenDuration(originalDefaultOpenDuration), endpoint_id=endpoint)
+
 
 if __name__ == "__main__":
     default_matter_test_main()