Skip to content

Commit

Permalink
move staticmethods inside the class
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed May 14, 2024
1 parent bc46eb2 commit d7c299c
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/python_testing/TC_ICDM_2_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,24 @@
kUatColorInstructionBitMask = uat.kActuateSensorLightsBlink | uat.kResetButtonLightsBlink | uat.kSetupButtonLightsBlink


@staticmethod
def is_valid_uint32_value(var):
return isinstance(var, int) and 0 <= var <= 0xFFFFFFFF


@staticmethod
def is_valid_uint16_value(var):
return isinstance(var, int) and 0 <= var <= 0xFFFF


@staticmethod
def is_valid_uint8_value(var):
return isinstance(var, int) and 0 <= var <= 0xFF


class TC_ICDM_2_1(MatterBaseTest):

#
# Class Helper functions
#

@staticmethod
def is_valid_uint32_value(var):
return isinstance(var, int) and 0 <= var <= 0xFFFFFFFF

@staticmethod
def is_valid_uint16_value(var):
return isinstance(var, int) and 0 <= var <= 0xFFFF

@staticmethod
def is_valid_uint8_value(var):
return isinstance(var, int) and 0 <= var <= 0xFF

async def _read_icdm_attribute_expect_success(self, attribute):
return await self.read_single_attribute_check_success(endpoint=kRootEndpointId, cluster=cluster, attribute=attribute)

Expand Down Expand Up @@ -128,7 +125,7 @@ async def test_TC_ICDM_2_1(self):
activeModeThreshold = await self._read_icdm_attribute_expect_success(
attributes.ActiveModeThreshold)
# Verify ActiveModeThreshold is not bigger than uint16
asserts.assert_true(is_valid_uint16_value(activeModeThreshold),
asserts.assert_true(self.is_valid_uint16_value(activeModeThreshold),
"ActiveModeThreshold attribute does not fit in a uint16.")

if featureMap > 0 and features.kLongIdleTimeSupport in features(featureMap):
Expand All @@ -145,7 +142,7 @@ async def test_TC_ICDM_2_1(self):
activeModeDuration = await self._read_icdm_attribute_expect_success(
attributes.ActiveModeDuration)
# Verify ActiveModeDuration is not bigger than uint32
asserts.assert_true(is_valid_uint32_value(activeModeDuration),
asserts.assert_true(self.is_valid_uint32_value(activeModeDuration),
"ActiveModeDuration attribute does not fit in a uint32")
else:
asserts.assert_true(
Expand Down Expand Up @@ -174,7 +171,7 @@ async def test_TC_ICDM_2_1(self):
attributes.ClientsSupportedPerFabric)

# Verify ClientsSupportedPerFabric is not bigger than uint16
asserts.assert_true(is_valid_uint16_value(clientsSupportedPerFabric),
asserts.assert_true(self.is_valid_uint16_value(clientsSupportedPerFabric),
"ClientsSupportedPerFabric attribute does not fit in a uint16.")

asserts.assert_greater_equal(
Expand All @@ -196,7 +193,7 @@ async def test_TC_ICDM_2_1(self):
icdCounter = await self._read_icdm_attribute_expect_success(
attributes.ICDCounter)
# Verify ICDCounter is not bigger than uint32
asserts.assert_true(is_valid_uint32_value(icdCounter),
asserts.assert_true(self.is_valid_uint32_value(icdCounter),
"ActiveModeDuration attribute does not fit in a uint32")

# Validate UserActiveModeTriggerHint
Expand Down Expand Up @@ -253,7 +250,7 @@ async def test_TC_ICDM_2_1(self):
operatingMode = await self._read_icdm_attribute_expect_success(
attributes.OperatingMode)

asserts.assert_true(is_valid_uint8_value(operatingMode),
asserts.assert_true(self.is_valid_uint8_value(operatingMode),
"OperatingMode does not fit in an enum8")

asserts.assert_less(
Expand Down

0 comments on commit d7c299c

Please sign in to comment.