Skip to content

Commit

Permalink
Update DataWriter/Reader get_matched_publication/subscription...()
Browse files Browse the repository at this point in the history
…API tests (#188)

* Refs #21808: Update tests as result of 3.x API implementation

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #21808: Improve tests asserting positives and negatives cases

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #21808: Apply second rev

Signed-off-by: Mario Dominguez <[email protected]>

---------

Signed-off-by: Mario Dominguez <[email protected]>
  • Loading branch information
Mario-DL authored Oct 25, 2024
1 parent f0ef709 commit ecc860d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
19 changes: 15 additions & 4 deletions fastdds_python/test/api/test_datareader.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,25 +773,36 @@ def test_get_liveliness_changed_status(datareader):
assert(fastdds.c_InstanceHandle_Unknown == status.last_publication_handle)


def test_get_matched_publication_data(datareader):
def test_get_matched_publication_data(datareader, datawriter):
"""
This test checks:
- DataReader::get_matched_publication_data
"""
# Check with an invalid instance handle
pub_data = fastdds.PublicationBuiltinTopicData()
ih = fastdds.InstanceHandle_t()
assert(fastdds.RETCODE_UNSUPPORTED ==
assert(fastdds.RETCODE_BAD_PARAMETER ==
datareader.get_matched_publication_data(pub_data, ih))

time.sleep(1)
# Check with the writer's instance handle
assert(fastdds.RETCODE_OK ==
datareader.get_matched_publication_data(pub_data, datawriter.get_instance_handle()))
assert(pub_data.guid == datawriter.guid())

def test_get_matched_publications(datareader):
def test_get_matched_publications(datareader, datawriter):
"""
This test checks:
- DataReader::get_matched_publications
"""
ihs = fastdds.InstanceHandleVector()
assert(fastdds.RETCODE_UNSUPPORTED ==
time.sleep(1)
assert(fastdds.RETCODE_OK ==
datareader.get_matched_publications(ihs))
# The datawriter (added in the fixture) is the only
# one that should be matched
assert(1 == ihs.size())
assert(ihs[0] == datawriter.get_instance_handle())


def test_get_requested_deadline_missed_status(datareader):
Expand Down
35 changes: 29 additions & 6 deletions fastdds_python/test/api/test_datawriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ def subscriber(reader_participant):
return reader_participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT)


@pytest.fixture
def datareader(reader_participant, reader_topic, subscriber):
datareader = subscriber.create_datareader(
reader_topic, fastdds.DATAREADER_QOS_DEFAULT)

yield datareader

assert(fastdds.RETCODE_OK ==
subscriber.delete_datareader(datareader))
assert(fastdds.RETCODE_OK ==
reader_participant.delete_topic(reader_topic))
assert(fastdds.RETCODE_OK ==
reader_participant.delete_subscriber(subscriber))
factory = fastdds.DomainParticipantFactory.get_instance()
assert(fastdds.RETCODE_OK ==
factory.delete_participant(reader_participant))

def test_assert_liveliness(manual_liveliness_datawriter_qos, datawriter):
"""
This test checks:
Expand Down Expand Up @@ -308,26 +325,32 @@ def test_get_liveliness_lost_status(datawriter):
assert(0 == status.total_count_change)


def test_get_matched_subscription_data(datawriter):
def test_get_matched_subscription_data(datawriter, datareader):
"""
This test checks:
- DataWriter::get_matched_subscription_data
"""
# Check with an invalid instance handle
sub_data = fastdds.SubscriptionBuiltinTopicData()
ih = fastdds.InstanceHandle_t()
assert(fastdds.RETCODE_UNSUPPORTED ==
assert(fastdds.RETCODE_BAD_PARAMETER ==
datawriter.get_matched_subscription_data(sub_data, ih))

time.sleep(1)
assert(fastdds.RETCODE_OK ==
datawriter.get_matched_subscription_data(sub_data, datareader.get_instance_handle()))
assert(sub_data.guid == datareader.guid())

def test_get_matched_subscriptions(datawriter):
def test_get_matched_subscriptions(datawriter, datareader):
"""
This test checks:
- DataWriter::get_matched_subscriptions
"""
ihs = fastdds.InstanceHandleVector()
assert(fastdds.RETCODE_UNSUPPORTED ==
datawriter.get_matched_subscriptions(ihs))

time.sleep(1)
assert(fastdds.RETCODE_OK == datawriter.get_matched_subscriptions(ihs))
assert(1 == ihs.size())
assert(ihs[0] == datareader.get_instance_handle())

def test_get_offered_deadline_missed_status(datawriter):
"""
Expand Down

0 comments on commit ecc860d

Please sign in to comment.