Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Eliminate ZCLSubscribeAttribute #33337

Merged
merged 9 commits into from
May 13, 2024
219 changes: 107 additions & 112 deletions src/controller/python/test/test_scripts/base.py

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/controller/python/test/test_scripts/mobile-device-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ def TestDatamodel(test: BaseTestHelper, device_nodeid: int):
"Failed to test Read Basic Attributes")

logger.info("Testing attribute writing")
FailIfNot(test.TestWriteBasicAttributes(nodeid=device_nodeid,
endpoint=ENDPOINT_ID,
group=GROUP_ID),
FailIfNot(asyncio.run(test.TestWriteBasicAttributes(nodeid=device_nodeid,
endpoint=ENDPOINT_ID)),
"Failed to test Write Basic Attributes")

logger.info("Testing attribute reading basic again")
Expand All @@ -141,11 +140,11 @@ def TestDatamodel(test: BaseTestHelper, device_nodeid: int):
"Failed to test Read Basic Attributes")

logger.info("Testing subscription")
FailIfNot(test.TestSubscription(nodeid=device_nodeid, endpoint=LIGHTING_ENDPOINT_ID),
FailIfNot(asyncio.run(test.TestSubscription(nodeid=device_nodeid, endpoint=LIGHTING_ENDPOINT_ID)),
"Failed to subscribe attributes.")

logger.info("Testing another subscription that kills previous subscriptions")
FailIfNot(test.TestSubscription(nodeid=device_nodeid, endpoint=LIGHTING_ENDPOINT_ID),
FailIfNot(asyncio.run(test.TestSubscription(nodeid=device_nodeid, endpoint=LIGHTING_ENDPOINT_ID)),
"Failed to subscribe attributes.")

logger.info("Testing re-subscription")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# Commissioning test.

import asyncio
import os
import sys
from optparse import OptionParser
Expand Down Expand Up @@ -113,8 +114,8 @@ def main():
"Failed on on-network commissioing")

FailIfNot(
test.TestSubscriptionResumptionCapacityStep1(
options.nodeid, TEST_ENDPOINT_ID, options.setuppin, options.subscriptionCapacity),
asyncio.run(test.TestSubscriptionResumptionCapacityStep1(
options.nodeid, TEST_ENDPOINT_ID, options.setuppin, options.subscriptionCapacity)),
"Failed on step 1 of testing subscription resumption capacity")

timeoutTicker.stop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# Commissioning test.

import asyncio
import os
import sys
from optparse import OptionParser
Expand Down Expand Up @@ -125,8 +126,9 @@ def main():
"Failed on on-network commissioing")

FailIfNot(
test.TestSubscriptionResumptionCapacityStep2(options.nodeid, TEST_ENDPOINT_ID, options.deviceAddress,
TEST_SSH_PORT, options.remoteServerApp, options.subscriptionCapacity),
asyncio.run(
test.TestSubscriptionResumptionCapacityStep2(options.nodeid, TEST_ENDPOINT_ID, options.deviceAddress,
TEST_SSH_PORT, options.remoteServerApp, options.subscriptionCapacity)),
"Failed on testing subscription resumption capacity")

timeoutTicker.stop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

# Commissioning test.

import asyncio
import os
import sys
from optparse import OptionParser
Expand Down Expand Up @@ -115,8 +116,8 @@ def main():
"Failed on on-network commissioing")

FailIfNot(
test.TestSubscriptionResumption(options.nodeid, TEST_ENDPOINT_ID, options.deviceAddress,
TEST_SSH_PORT, options.remoteServerApp), "Failed to resume subscription")
asyncio.run(test.TestSubscriptionResumption(options.nodeid, TEST_ENDPOINT_ID, options.deviceAddress,
TEST_SSH_PORT, options.remoteServerApp)), "Failed to resume subscription")

timeoutTicker.stop()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

# Commissioning test.

import asyncio
import os
import sys
from optparse import OptionParser

from base import BaseTestHelper, FailIfNot, TestFail, TestTimeout, logger
from chip import clusters as Clusters

TEST_DISCRIMINATOR = 3840
TEST_SETUPPIN = 20202021
Expand Down Expand Up @@ -101,10 +103,12 @@ def main():

FailIfNot(
test.TestOnNetworkCommissioning(options.discriminator, options.setuppin, options.nodeid, options.deviceAddress),
"Failed on on-network commissioing")
"Failed on on-network commissioning")

try:
test.devCtrl.ZCLSubscribeAttribute("BasicInformation", "NodeLabel", options.nodeid, TEST_ENDPOINT_ID, 1, 2,
keepSubscriptions=True, autoResubscribe=False)
asyncio.run(test.devCtrl.ReadAttribute(options.nodeid,
[(TEST_ENDPOINT_ID, Clusters.BasicInformation.Attributes.NodeLabel)],
None, False, reportInterval=(1, 2), keepSubscriptions=True, autoResubscribe=False))
except Exception as ex:
TestFail(f"Failed to subscribe attribute: {ex}")

Expand Down
Loading