From f0400826a0a2083084c08041eb0dd12ab7f35718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Wed, 16 Mar 2022 16:22:33 +0100 Subject: [PATCH 1/8] Refs #13384. Add fixtures to datareader api tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- fastdds_python/test/api/test_datareader.py | 1258 +++++--------------- 1 file changed, 273 insertions(+), 985 deletions(-) diff --git a/fastdds_python/test/api/test_datareader.py b/fastdds_python/test/api/test_datareader.py index 103025f8..d311a696 100644 --- a/fastdds_python/test/api/test_datareader.py +++ b/fastdds_python/test/api/test_datareader.py @@ -6,6 +6,7 @@ win32api.LoadLibrary('test_complete') import fastdds +import pytest import test_complete @@ -14,40 +15,32 @@ def __init__(self): super().__init__() -def create_querycondition(): - """ - This test checks: - - DataReader::create_querycondition - - DataReader::delete_contained_entities - """ +@pytest.fixture +def datareader_qos(): + return fastdds.DataReaderQos() + + +@pytest.fixture +def transient_datareader_qos(datareader_qos): + datareader_qos.durability().kind = fastdds.TRANSIENT_LOCAL_DURABILITY_QOS + datareader_qos.reliability().kind = fastdds.RELIABLE_RELIABILITY_QOS + return datareader_qos + + +@pytest.fixture +def complete_datareader(datareader_qos): factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) participant = factory.create_participant( 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) test_type = fastdds.TypeSupport( test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) + participant.register_type(test_type, test_type.get_type_name()) topic = participant.create_topic( "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - - sv = fastdds.SampleStateKindVector() - vv = fastdds.ViewStateKindVector() - iv = fastdds.InstanceStateKindVector() - qp = fastdds.StringVector() + datareader = subscriber.create_datareader(topic, datareader_qos) - querycondition = datareader.create_querycondition( - sv, vv, iv, "", qp) - assert(querycondition is None) - assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.delete_contained_entities()) + yield datareader assert(fastdds.ReturnCode_t.RETCODE_OK == subscriber.delete_datareader(datareader)) @@ -59,38 +52,20 @@ def create_querycondition(): factory.delete_participant(participant)) -def test_create_readcondition(): - """ - This test checks: - - DataReader::create_readcondition - - DataReader::delete_readcondition - """ +@pytest.fixture +def keyedcomplete_datareader(datareader_qos): factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) participant = factory.create_participant( 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) test_type = fastdds.TypeSupport( - test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) + test_complete.KeyedCompleteTestTypePubSubType()) + participant.register_type(test_type, test_type.get_type_name()) topic = participant.create_topic( "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) + datareader = subscriber.create_datareader(topic, datareader_qos) - sv = fastdds.SampleStateKindVector() - vv = fastdds.ViewStateKindVector() - iv = fastdds.InstanceStateKindVector() - readcondition = datareader.create_readcondition( - sv, vv, iv) - assert(readcondition is None) - assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - datareader.delete_readcondition(readcondition)) + yield datareader assert(fastdds.ReturnCode_t.RETCODE_OK == subscriber.delete_datareader(datareader)) @@ -102,147 +77,149 @@ def test_create_readcondition(): factory.delete_participant(participant)) -def test_get_first_untaken(): - """ - This test checks: - - DataReader::get_first_untaken_info - """ +@pytest.fixture +def complete_datawriter(): factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) participant = factory.create_participant( 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) + publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) test_type = fastdds.TypeSupport( test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) + participant.register_type(test_type, test_type.get_type_name()) topic = participant.create_topic( "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader_qos = fastdds.DataReaderQos() - datareader_qos.durability().kind = fastdds.TRANSIENT_LOCAL_DURABILITY_QOS - datareader = subscriber.create_datareader( - topic, datareader_qos) - assert(datareader is not None) - - info = fastdds.SampleInfo() - assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - datareader.get_first_untaken_info(info)) - - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) datawriter = publisher.create_datawriter( topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - sample = test_complete.CompleteTestType() - sample.int16_field(255) - assert(datawriter.write(sample)) - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.get_first_untaken_info(info)) - assert(info.valid_data) + yield datawriter assert(fastdds.ReturnCode_t.RETCODE_OK == publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.delete_topic(topic)) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) assert(fastdds.ReturnCode_t.RETCODE_OK == factory.delete_participant(participant)) -def test_get_instance_handle(): - """ - This test checks: - - DataReader::guid - - DataReader::get_instance_handle - """ +@pytest.fixture +def keyedcomplete_datawriter(): factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) participant = factory.create_participant( 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) + publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) test_type = fastdds.TypeSupport( test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) + participant.register_type(test_type, test_type.get_type_name()) topic = participant.create_topic( "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - - guid = datareader.guid() - assert(fastdds.c_Guid_Unknown != guid) - ih = datareader.get_instance_handle() - assert(fastdds.c_InstanceHandle_Unknown != ih) - - for i in range(0, 12): - assert(guid.guidPrefix.value[i] == ih.value[i]) + datawriter = publisher.create_datawriter( + topic, fastdds.DATAWRITER_QOS_DEFAULT) - for i in range(0, 4): - assert(guid.entityId.value[i] == ih.value[12+i]) + yield datawriter assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) + publisher.delete_datawriter(datawriter)) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.delete_topic(topic)) assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) + participant.delete_publisher(publisher)) assert(fastdds.ReturnCode_t.RETCODE_OK == factory.delete_participant(participant)) -def test_get_key_value(): +def test_create_querycondition(complete_datareader): """ This test checks: - - DataReader::get_key_value + - DataReader::create_querycondition + - DataReader::delete_contained_entities """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) + sv = fastdds.SampleStateKindVector() + vv = fastdds.ViewStateKindVector() + iv = fastdds.InstanceStateKindVector() + qp = fastdds.StringVector() + + querycondition = complete_datareader.create_querycondition( + sv, vv, iv, "", qp) + assert(querycondition is None) assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) + complete_datareader.delete_contained_entities()) + + +def test_create_readcondition(complete_datareader): + """ + This test checks: + - DataReader::create_readcondition + - DataReader::delete_readcondition + """ + sv = fastdds.SampleStateKindVector() + vv = fastdds.ViewStateKindVector() + iv = fastdds.InstanceStateKindVector() + readcondition = complete_datareader.create_readcondition( + sv, vv, iv) + assert(readcondition is None) + assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == + complete_datareader.delete_readcondition(readcondition)) + + +def test_get_first_untaken(transient_datareader_qos, complete_datareader, + complete_datawriter): + """ + This test checks: + - DataReader::get_first_untaken_info + """ + info = fastdds.SampleInfo() + assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == + complete_datareader.get_first_untaken_info(info)) + qos = complete_datareader.get_qos() + assert(fastdds.TRANSIENT_LOCAL_DURABILITY_QOS == qos.durability().kind) + qos = complete_datawriter.get_qos() + assert(fastdds.TRANSIENT_LOCAL_DURABILITY_QOS == qos.durability().kind) + + sample = test_complete.CompleteTestType() + sample.int16_field(255) + assert(complete_datawriter.write(sample)) + + assert(complete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) + assert(fastdds.ReturnCode_t.RETCODE_OK == + complete_datareader.get_first_untaken_info(info)) + assert(info.valid_data) + +def test_get_instance_handle(complete_datareader): + """ + This test checks: + - DataReader::guid + - DataReader::get_instance_handle + """ + guid = complete_datareader.guid() + assert(fastdds.c_Guid_Unknown != guid) + ih = complete_datareader.get_instance_handle() + assert(fastdds.c_InstanceHandle_Unknown != ih) + + for i in range(0, 12): + assert(guid.guidPrefix.value[i] == ih.value[i]) + + for i in range(0, 4): + assert(guid.entityId.value[i] == ih.value[12+i]) + + +def test_get_key_value(keyedcomplete_datareader): + """ + This test checks: + - DataReader::get_key_value + """ sample = test_complete.KeyedCompleteTestType() + sample.id(255) ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - datareader.get_key_value(sample, ih)) + keyedcomplete_datareader.get_key_value(sample, ih)) assert(fastdds.c_InstanceHandle_Unknown == ih) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_set_listener(): +def test_get_set_listener(complete_datareader): """ This test checks: - DataReader::get_listener @@ -251,31 +228,14 @@ def test_get_set_listener(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - # Overload 1 listener = DataReaderListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.set_listener(listener)) - assert(datareader.get_listener() == listener) - assert(fastdds.StatusMask.all() == datareader.get_status_mask()) + complete_datareader.set_listener(listener)) + assert(complete_datareader.get_listener() == listener) + assert(fastdds.StatusMask.all() == + complete_datareader.get_status_mask()) def test(status_mask_1, status_mask_2): """ @@ -284,15 +244,15 @@ def test(status_mask_1, status_mask_2): listener = DataReaderListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.set_listener(listener, status_mask_1)) - assert(datareader.get_listener() == listener) - assert(status_mask_1 == datareader.get_status_mask()) + complete_datareader.set_listener(listener, status_mask_1)) + assert(complete_datareader.get_listener() == listener) + assert(status_mask_1 == complete_datareader.get_status_mask()) listener = DataReaderListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.set_listener(listener, status_mask_2)) - assert(datareader.get_listener() == listener) - assert(status_mask_2 == datareader.get_status_mask()) + complete_datareader.set_listener(listener, status_mask_2)) + assert(complete_datareader.get_listener() == listener) + assert(status_mask_2 == complete_datareader.get_status_mask()) # Overload 2: Different status masks test(fastdds.StatusMask.all(), fastdds.StatusMask_all()) @@ -354,237 +314,75 @@ def test(status_mask_1, status_mask_2): fastdds.StatusMask.subscription_matched(), m) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_listening_locators(): +def test_get_listening_locators(complete_datareader): """ This test checks: - DataReader::get_listening_locators """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - locator_list = fastdds.LocatorList() assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.get_listening_locators(locator_list)) + complete_datareader.get_listening_locators(locator_list)) assert(0 < locator_list.size()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_liveliness_changed_status(): +def test_get_liveliness_changed_status(complete_datareader): """ This test checks: - DataReader::get_liveliness_changed_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) + status = fastdds.LivelinessChangedStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - - status = fastdds.LivelinessChangedStatus() - assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.get_liveliness_changed_status(status)) + complete_datareader.get_liveliness_changed_status(status)) assert(0 == status.alive_count) assert(0 == status.alive_count_change) assert(0 == status.not_alive_count) assert(0 == status.not_alive_count_change) assert(fastdds.c_InstanceHandle_Unknown == status.last_publication_handle) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_matched_publication_data(): +def test_get_matched_publication_data(complete_datareader): """ This test checks: - DataWriter::get_matched_publication_data """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - pub_data = fastdds.PublicationBuiltinTopicData() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - datareader.get_matched_publication_data(pub_data, ih)) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + complete_datareader.get_matched_publication_data(pub_data, ih)) -def test_get_matched_publications(): +def test_get_matched_publications(complete_datareader): """ This test checks: - DataReader::get_matched_publications """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - ihs = fastdds.InstanceHandleVector() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - datareader.get_matched_publications(ihs)) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + complete_datareader.get_matched_publications(ihs)) -def test_get_requested_deadline_missed_status(): +def test_get_requested_deadline_missed_status(complete_datareader): """ This test checks: - DataReader::get_requested_deadline_missed_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - status = fastdds.RequestedDeadlineMissedStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.get_requested_deadline_missed_status(status)) + complete_datareader.get_requested_deadline_missed_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) assert(fastdds.c_InstanceHandle_Unknown == status.last_instance_handle) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_requested_incompatible_qos_status(): +def test_get_requested_incompatible_qos_status(complete_datareader): """ This test checks: - DataReader::get_requested_deadline_missed_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - status = fastdds.RequestedIncompatibleQosStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.get_requested_incompatible_qos_status(status)) + complete_datareader.get_requested_incompatible_qos_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) assert(fastdds.INVALID_QOS_POLICY_ID == status.last_policy_id) @@ -595,135 +393,45 @@ def test_get_requested_incompatible_qos_status(): assert(id == policy.policy_id) id += 1 - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_sample_lost_status(): +def test_get_sample_lost_status(complete_datareader): """ This test checks: - DataReader::get_sample_lost_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - status = fastdds.SampleLostStatus() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - datareader.get_sample_lost_status(status)) + complete_datareader.get_sample_lost_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_sample_rejected_status(): +def test_get_sample_rejected_status(complete_datareader): """ This test checks: - DataReader::get_sample_rejected_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - status = fastdds.SampleRejectedStatus() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - datareader.get_sample_rejected_status(status)) + complete_datareader.get_sample_rejected_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_subscription_matched_status(): +def test_get_subscription_matched_status(complete_datareader): """ This test checks: - DataReader::get_subscription_matched_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - status = fastdds.SubscriptionMatchedStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.get_subscription_matched_status(status)) + complete_datareader.get_subscription_matched_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) assert(0 == status.current_count) assert(0 == status.current_count_change) assert(fastdds.c_InstanceHandle_Unknown == status.last_publication_handle) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - def test_get_subscriber(): """ @@ -798,197 +506,78 @@ def test_get_topicdescription(): factory.delete_participant(participant)) -def test_get_unread_count(): +def test_get_unread_count(transient_datareader_qos, complete_datareader, + complete_datawriter): """ This test checks: - DataReader::get_unread_count """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader_qos = fastdds.DataReaderQos() - datareader_qos.durability().kind = fastdds.TRANSIENT_LOCAL_DURABILITY_QOS - datareader = subscriber.create_datareader( - topic, datareader_qos) - assert(datareader is not None) - - assert(0 == datareader.get_unread_count()) + assert(0 == complete_datareader.get_unread_count()) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(datawriter.write(sample)) - - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) - assert(1 == datareader.get_unread_count()) + assert(complete_datawriter.write(sample)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + assert(complete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) + assert(1 == complete_datareader.get_unread_count()) -def test_is_sample_valid(): +def test_is_sample_valid(transient_datareader_qos, complete_datareader, + complete_datawriter): """ This test checks: - DataReader::is_sample_valid """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.CompleteTestTypePubSubType()) + sample = test_complete.CompleteTestType() + sample.int16_field(255) + assert(complete_datawriter.write(sample)) + + assert(complete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) + data = test_complete.CompleteTestType() + info = fastdds.SampleInfo() assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader_qos = fastdds.DataReaderQos() - datareader_qos.durability().kind = fastdds.TRANSIENT_LOCAL_DURABILITY_QOS - datareader = subscriber.create_datareader( - topic, datareader_qos) - assert(datareader is not None) - - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - sample = test_complete.CompleteTestType() - sample.int16_field(255) - assert(datawriter.write(sample)) - - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) - data = test_complete.CompleteTestType() - info = fastdds.SampleInfo() - assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.read_next_sample(data, info)) - assert(datareader.is_sample_valid(data, info)) + complete_datareader.read_next_sample(data, info)) + assert(complete_datareader.is_sample_valid(data, info)) assert(sample.int16_field() == data.int16_field()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_lookup_instance(): +def test_lookup_instance(keyedcomplete_datareader): """ This test checks: - DataReader::lookup_instance """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - sample = test_complete.KeyedCompleteTestType() sample.id(3) - ih = datareader.lookup_instance(sample) + ih = keyedcomplete_datareader.lookup_instance(sample) assert(fastdds.c_InstanceHandle_Unknown == ih) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_read(): +def test_read(transient_datareader_qos, complete_datareader, + complete_datawriter): """ This test checks: - DataReader::read - DataReader::return_loan """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - data_seq = test_complete.CompleteTestTypeSeq() info_seq = fastdds.SampleInfoSeq() - assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == datareader.read( - data_seq, info_seq, fastdds.LENGTH_UNLIMITED, - fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, - fastdds.ANY_INSTANCE_STATE)) + assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == + complete_datareader.read( + data_seq, info_seq, fastdds.LENGTH_UNLIMITED, + fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, + fastdds.ANY_INSTANCE_STATE)) assert(0 == len(data_seq)) assert(0 == len(info_seq)) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(datawriter.write(sample)) + assert(complete_datawriter.write(sample)) - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == datareader.read( + assert(complete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) + assert(fastdds.ReturnCode_t.RETCODE_OK == complete_datareader.read( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -997,266 +586,132 @@ def test_read(): assert(info_seq[0].valid_data is True) assert(sample.int16_field() == data_seq[0].int16_field()) assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.return_loan(data_seq, info_seq)) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + complete_datareader.return_loan(data_seq, info_seq)) -def test_read_instance(): +def test_read_instance(transient_datareader_qos, keyedcomplete_datareader, + keyedcomplete_datawriter): """ This test checks: - DataReader::read_instance - DataReader::return_loan """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - data_seq = test_complete.KeyedCompleteTestTypeSeq() info_seq = fastdds.SampleInfoSeq() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_BAD_PARAMETER == - datareader.read_instance( + keyedcomplete_datareader.read_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) assert(0 == len(data_seq)) assert(0 == len(info_seq)) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) sample = test_complete.KeyedCompleteTestType() - sample.int16_field(255) - ih = datawriter.register_instance(sample) - assert(datawriter.write(sample, ih)) + sample.id(255) + ih = keyedcomplete_datawriter.register_instance(sample) + assert(keyedcomplete_datawriter.write(sample, ih)) - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == datareader.read_instance( - data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, - fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, - fastdds.ANY_INSTANCE_STATE)) + assert(keyedcomplete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) + assert(fastdds.ReturnCode_t.RETCODE_OK == + keyedcomplete_datareader.read_instance( + data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, + fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, + fastdds.ANY_INSTANCE_STATE)) assert(1 == len(data_seq)) assert(1 == len(info_seq)) assert(info_seq[0].valid_data is True) - assert(sample.int16_field() == data_seq[0].int16_field()) + assert(sample.id() == data_seq[0].id()) assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.return_loan(data_seq, info_seq)) + keyedcomplete_datareader.return_loan(data_seq, info_seq)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_read_next_instance(): +def test_read_next_instance(transient_datareader_qos, keyedcomplete_datareader, + keyedcomplete_datawriter): """ This test checks: - DataReader::read_next_instance - DataReader::return_loan """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - data_seq = test_complete.KeyedCompleteTestTypeSeq() info_seq = fastdds.SampleInfoSeq() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - datareader.read_next_instance( + keyedcomplete_datareader.read_next_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) assert(0 == len(data_seq)) assert(0 == len(info_seq)) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) sample = test_complete.KeyedCompleteTestType() - sample.int16_field(255) - assert(datawriter.write(sample)) + sample.id(255) + assert(keyedcomplete_datawriter.write(sample)) - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == datareader.read_next_instance( - data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, - fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, - fastdds.ANY_INSTANCE_STATE)) + assert(keyedcomplete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) + assert(fastdds.ReturnCode_t.RETCODE_OK == + keyedcomplete_datareader.read_next_instance( + data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, + fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, + fastdds.ANY_INSTANCE_STATE)) assert(1 == len(data_seq)) assert(1 == len(info_seq)) assert(info_seq[0].valid_data is True) - assert(sample.int16_field() == data_seq[0].int16_field()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.return_loan(data_seq, info_seq)) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) + assert(sample.id() == data_seq[0].id()) assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + keyedcomplete_datareader.return_loan(data_seq, info_seq)) -def test_read_next_sample(): +def test_read_next_sample(transient_datareader_qos, complete_datareader, + complete_datawriter): """ This test checks: - DataReader::read_next_sample """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader_qos = fastdds.DataReaderQos() - datareader_qos.durability().kind = fastdds.TRANSIENT_LOCAL_DURABILITY_QOS - datareader = subscriber.create_datareader( - topic, datareader_qos) - assert(datareader is not None) - data = test_complete.CompleteTestType() info = fastdds.SampleInfo() - assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == datareader.read_next_sample( - data, info)) + assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == + complete_datareader.read_next_sample( + data, info)) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(datawriter.write(sample)) + assert(complete_datawriter.write(sample)) - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) + assert(complete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.read_next_sample(data, info)) + complete_datareader.read_next_sample(data, info)) assert(info.valid_data) assert(sample.int16_field() == data.int16_field()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_take(): +def test_take(transient_datareader_qos, complete_datareader, + complete_datawriter): """ This test checks: - DataReader::take - DataReader::return_loan """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - data_seq = test_complete.CompleteTestTypeSeq() info_seq = fastdds.SampleInfoSeq() - assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == datareader.take( - data_seq, info_seq, fastdds.LENGTH_UNLIMITED, - fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, - fastdds.ANY_INSTANCE_STATE)) + assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == + complete_datareader.take( + data_seq, info_seq, fastdds.LENGTH_UNLIMITED, + fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, + fastdds.ANY_INSTANCE_STATE)) assert(0 == len(data_seq)) assert(0 == len(info_seq)) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(datawriter.write(sample)) + assert(complete_datawriter.write(sample)) - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == datareader.take( + assert(complete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) + assert(fastdds.ReturnCode_t.RETCODE_OK == complete_datareader.take( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -1265,221 +720,107 @@ def test_take(): assert(info_seq[0].valid_data is True) assert(sample.int16_field() == data_seq[0].int16_field()) assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.return_loan(data_seq, info_seq)) + complete_datareader.return_loan(data_seq, info_seq)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_take_instance(): +def test_take_instance(transient_datareader_qos, keyedcomplete_datareader, + keyedcomplete_datawriter): """ This test checks: - DataReader::take_instance - DataReader::return_loan """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - data_seq = test_complete.KeyedCompleteTestTypeSeq() info_seq = fastdds.SampleInfoSeq() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_BAD_PARAMETER == - datareader.take_instance( + keyedcomplete_datareader.take_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) assert(0 == len(data_seq)) assert(0 == len(info_seq)) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) sample = test_complete.KeyedCompleteTestType() - sample.int16_field(255) - ih = datawriter.register_instance(sample) - assert(datawriter.write(sample, ih)) + sample.id(255) + ih = keyedcomplete_datawriter.register_instance(sample) + assert(keyedcomplete_datawriter.write(sample, ih)) - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == datareader.take_instance( - data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, - fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, - fastdds.ANY_INSTANCE_STATE)) + assert(keyedcomplete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) + assert(fastdds.ReturnCode_t.RETCODE_OK == + keyedcomplete_datareader.take_instance( + data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, + fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, + fastdds.ANY_INSTANCE_STATE)) assert(1 == len(data_seq)) assert(1 == len(info_seq)) assert(info_seq[0].valid_data is True) - assert(sample.int16_field() == data_seq[0].int16_field()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.return_loan(data_seq, info_seq)) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) + assert(sample.id() == data_seq[0].id()) assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + keyedcomplete_datareader.return_loan(data_seq, info_seq)) -def test_take_next_instance(): +def test_take_next_instance(transient_datareader_qos, keyedcomplete_datareader, + keyedcomplete_datawriter): """ This test checks: - DataReader::take_next_instance - DataReader::return_loan """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - data_seq = test_complete.KeyedCompleteTestTypeSeq() info_seq = fastdds.SampleInfoSeq() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - datareader.take_next_instance( + keyedcomplete_datareader.take_next_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) assert(0 == len(data_seq)) assert(0 == len(info_seq)) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) sample = test_complete.KeyedCompleteTestType() - sample.int16_field(255) - assert(datawriter.write(sample)) + sample.id(255) + assert(keyedcomplete_datawriter.write(sample)) - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == datareader.take_next_instance( - data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, - fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, - fastdds.ANY_INSTANCE_STATE)) + assert(keyedcomplete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) + assert(fastdds.ReturnCode_t.RETCODE_OK == + keyedcomplete_datareader.take_next_instance( + data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, + fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, + fastdds.ANY_INSTANCE_STATE)) assert(1 == len(data_seq)) assert(1 == len(info_seq)) assert(info_seq[0].valid_data is True) - assert(sample.int16_field() == data_seq[0].int16_field()) + assert(sample.id() == data_seq[0].id()) assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.return_loan(data_seq, info_seq)) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + keyedcomplete_datareader.return_loan(data_seq, info_seq)) -def test_take_next_sample(): +def test_take_next_sample(transient_datareader_qos, complete_datareader, + complete_datawriter): """ This test checks: - DataReader::take_next_sample """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader_qos = fastdds.DataReaderQos() - datareader_qos.durability().kind = fastdds.TRANSIENT_LOCAL_DURABILITY_QOS - datareader = subscriber.create_datareader( - topic, datareader_qos) - assert(datareader is not None) - data = test_complete.CompleteTestType() info = fastdds.SampleInfo() - assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == datareader.take_next_sample( - data, info)) + assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == + complete_datareader.take_next_sample( + data, info)) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(datawriter.write(sample)) + assert(complete_datawriter.write(sample)) - assert(datareader.wait_for_unread_message(fastdds.Duration_t(5, 0))) + assert(complete_datareader.wait_for_unread_message( + fastdds.Duration_t(5, 0))) assert(fastdds.ReturnCode_t.RETCODE_OK == - datareader.take_next_sample(data, info)) + complete_datareader.take_next_sample(data, info)) assert(info.valid_data) assert(sample.int16_field() == data.int16_field()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - def test_get_type(): """ @@ -1518,72 +859,19 @@ def test_get_type(): factory.delete_participant(participant)) -def test_wait_for_historical_data(): +def test_wait_for_historical_data(complete_datareader): """ This test checks: - DataReader::wait_for_historical_data """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - datareader.wait_for_historical_data(fastdds.Duration_t(0, 100))) + complete_datareader.wait_for_historical_data( + fastdds.Duration_t(0, 100))) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_wait_for_unread_message(): +def test_wait_for_unread_message(complete_datareader): """ This test checks: - DataReader::wait_for_unread_message """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - - assert(not datareader.wait_for_unread_message(fastdds.Duration_t(0, 100))) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + assert(not complete_datareader.wait_for_unread_message(fastdds.Duration_t(0, 100))) From f4e7d43baf16e21c40551109be284e3dc0437284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Wed, 16 Mar 2022 22:48:26 +0100 Subject: [PATCH 2/8] Refs #13384. Changes in fixtures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- .../src/swig/fastdds/dds/topic/TypeSupport.i | 7 + fastdds_python/test/api/test_datareader.py | 352 +++++++++--------- 2 files changed, 174 insertions(+), 185 deletions(-) diff --git a/fastdds_python/src/swig/fastdds/dds/topic/TypeSupport.i b/fastdds_python/src/swig/fastdds/dds/topic/TypeSupport.i index 1e9b71d1..02e47539 100644 --- a/fastdds_python/src/swig/fastdds/dds/topic/TypeSupport.i +++ b/fastdds_python/src/swig/fastdds/dds/topic/TypeSupport.i @@ -41,4 +41,11 @@ { return new eprosima::fastdds::dds::TypeSupport(ptr); } + + %apply SWIGTYPE *DISOWN { eprosima::fastdds::dds::TopicDataType* ptr }; + void set(eprosima::fastdds::dds::TopicDataType* ptr) + { + self->reset(ptr); + } + } diff --git a/fastdds_python/test/api/test_datareader.py b/fastdds_python/test/api/test_datareader.py index d311a696..9d3eb85a 100644 --- a/fastdds_python/test/api/test_datareader.py +++ b/fastdds_python/test/api/test_datareader.py @@ -15,6 +15,36 @@ def __init__(self): super().__init__() +@pytest.fixture +def participant(): + factory = fastdds.DomainParticipantFactory.get_instance() + return factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + +@pytest.fixture +def subscriber(participant): + return participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) + + +@pytest.fixture +def test_type(): + return fastdds.TypeSupport( + test_complete.CompleteTestTypePubSubType()) + + +@pytest.fixture +def test_keyed_type(test_type): + test_type.set(test_complete.KeyedCompleteTestTypePubSubType()) + + +@pytest.fixture +def topic(participant, test_type): + participant.register_type(test_type, test_type.get_type_name()) + return participant.create_topic( + "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) + + @pytest.fixture def datareader_qos(): return fastdds.DataReaderQos() @@ -28,16 +58,7 @@ def transient_datareader_qos(datareader_qos): @pytest.fixture -def complete_datareader(datareader_qos): - factory = fastdds.DomainParticipantFactory.get_instance() - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - test_type = fastdds.TypeSupport( - test_complete.CompleteTestTypePubSubType()) - participant.register_type(test_type, test_type.get_type_name()) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) +def datareader(participant, topic, subscriber, datareader_qos): datareader = subscriber.create_datareader(topic, datareader_qos) yield datareader @@ -48,88 +69,49 @@ def complete_datareader(datareader_qos): participant.delete_topic(topic)) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.delete_subscriber(subscriber)) + factory = fastdds.DomainParticipantFactory.get_instance() assert(fastdds.ReturnCode_t.RETCODE_OK == factory.delete_participant(participant)) @pytest.fixture -def keyedcomplete_datareader(datareader_qos): +def writer_participant(): factory = fastdds.DomainParticipantFactory.get_instance() - participant = factory.create_participant( + return factory.create_participant( 0, fastdds.PARTICIPANT_QOS_DEFAULT) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - participant.register_type(test_type, test_type.get_type_name()) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - datareader = subscriber.create_datareader(topic, datareader_qos) - - yield datareader - - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) @pytest.fixture -def complete_datawriter(): - factory = fastdds.DomainParticipantFactory.get_instance() - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - test_type = fastdds.TypeSupport( - test_complete.CompleteTestTypePubSubType()) - participant.register_type(test_type, test_type.get_type_name()) - topic = participant.create_topic( +def writer_topic(writer_participant, test_type): + writer_participant.register_type(test_type, test_type.get_type_name()) + return writer_participant.create_topic( "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - yield datawriter - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) +@pytest.fixture +def publisher(writer_participant): + return writer_participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) @pytest.fixture -def keyedcomplete_datawriter(): - factory = fastdds.DomainParticipantFactory.get_instance() - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - participant.register_type(test_type, test_type.get_type_name()) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) +def datawriter(writer_participant, writer_topic, publisher): datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) + writer_topic, fastdds.DATAWRITER_QOS_DEFAULT) yield datawriter assert(fastdds.ReturnCode_t.RETCODE_OK == publisher.delete_datawriter(datawriter)) assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) + writer_participant.delete_topic(writer_topic)) assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) + writer_participant.delete_publisher(publisher)) + factory = fastdds.DomainParticipantFactory.get_instance() assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + factory.delete_participant(writer_participant)) -def test_create_querycondition(complete_datareader): +def test_create_querycondition(datareader): """ This test checks: - DataReader::create_querycondition @@ -140,14 +122,14 @@ def test_create_querycondition(complete_datareader): iv = fastdds.InstanceStateKindVector() qp = fastdds.StringVector() - querycondition = complete_datareader.create_querycondition( + querycondition = datareader.create_querycondition( sv, vv, iv, "", qp) assert(querycondition is None) assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.delete_contained_entities()) + datareader.delete_contained_entities()) -def test_create_readcondition(complete_datareader): +def test_create_readcondition(datareader): """ This test checks: - DataReader::create_readcondition @@ -156,47 +138,47 @@ def test_create_readcondition(complete_datareader): sv = fastdds.SampleStateKindVector() vv = fastdds.ViewStateKindVector() iv = fastdds.InstanceStateKindVector() - readcondition = complete_datareader.create_readcondition( + readcondition = datareader.create_readcondition( sv, vv, iv) assert(readcondition is None) assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - complete_datareader.delete_readcondition(readcondition)) + datareader.delete_readcondition(readcondition)) -def test_get_first_untaken(transient_datareader_qos, complete_datareader, - complete_datawriter): +def test_get_first_untaken(transient_datareader_qos, datareader, + datawriter): """ This test checks: - DataReader::get_first_untaken_info """ info = fastdds.SampleInfo() assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - complete_datareader.get_first_untaken_info(info)) - qos = complete_datareader.get_qos() + datareader.get_first_untaken_info(info)) + qos = datareader.get_qos() assert(fastdds.TRANSIENT_LOCAL_DURABILITY_QOS == qos.durability().kind) - qos = complete_datawriter.get_qos() + qos = datawriter.get_qos() assert(fastdds.TRANSIENT_LOCAL_DURABILITY_QOS == qos.durability().kind) sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(complete_datawriter.write(sample)) + assert(datawriter.write(sample)) - assert(complete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.get_first_untaken_info(info)) + datareader.get_first_untaken_info(info)) assert(info.valid_data) -def test_get_instance_handle(complete_datareader): +def test_get_instance_handle(datareader): """ This test checks: - DataReader::guid - DataReader::get_instance_handle """ - guid = complete_datareader.guid() + guid = datareader.guid() assert(fastdds.c_Guid_Unknown != guid) - ih = complete_datareader.get_instance_handle() + ih = datareader.get_instance_handle() assert(fastdds.c_InstanceHandle_Unknown != ih) for i in range(0, 12): @@ -206,7 +188,7 @@ def test_get_instance_handle(complete_datareader): assert(guid.entityId.value[i] == ih.value[12+i]) -def test_get_key_value(keyedcomplete_datareader): +def test_get_key_value(test_keyed_type, datareader): """ This test checks: - DataReader::get_key_value @@ -215,11 +197,11 @@ def test_get_key_value(keyedcomplete_datareader): sample.id(255) ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - keyedcomplete_datareader.get_key_value(sample, ih)) + datareader.get_key_value(sample, ih)) assert(fastdds.c_InstanceHandle_Unknown == ih) -def test_get_set_listener(complete_datareader): +def test_get_set_listener(datareader): """ This test checks: - DataReader::get_listener @@ -232,10 +214,10 @@ def test_get_set_listener(complete_datareader): listener = DataReaderListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.set_listener(listener)) - assert(complete_datareader.get_listener() == listener) + datareader.set_listener(listener)) + assert(datareader.get_listener() == listener) assert(fastdds.StatusMask.all() == - complete_datareader.get_status_mask()) + datareader.get_status_mask()) def test(status_mask_1, status_mask_2): """ @@ -244,15 +226,15 @@ def test(status_mask_1, status_mask_2): listener = DataReaderListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.set_listener(listener, status_mask_1)) - assert(complete_datareader.get_listener() == listener) - assert(status_mask_1 == complete_datareader.get_status_mask()) + datareader.set_listener(listener, status_mask_1)) + assert(datareader.get_listener() == listener) + assert(status_mask_1 == datareader.get_status_mask()) listener = DataReaderListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.set_listener(listener, status_mask_2)) - assert(complete_datareader.get_listener() == listener) - assert(status_mask_2 == complete_datareader.get_status_mask()) + datareader.set_listener(listener, status_mask_2)) + assert(datareader.get_listener() == listener) + assert(status_mask_2 == datareader.get_status_mask()) # Overload 2: Different status masks test(fastdds.StatusMask.all(), fastdds.StatusMask_all()) @@ -315,25 +297,25 @@ def test(status_mask_1, status_mask_2): m) -def test_get_listening_locators(complete_datareader): +def test_get_listening_locators(datareader): """ This test checks: - DataReader::get_listening_locators """ locator_list = fastdds.LocatorList() assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.get_listening_locators(locator_list)) + datareader.get_listening_locators(locator_list)) assert(0 < locator_list.size()) -def test_get_liveliness_changed_status(complete_datareader): +def test_get_liveliness_changed_status(datareader): """ This test checks: - DataReader::get_liveliness_changed_status """ status = fastdds.LivelinessChangedStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.get_liveliness_changed_status(status)) + datareader.get_liveliness_changed_status(status)) assert(0 == status.alive_count) assert(0 == status.alive_count_change) assert(0 == status.not_alive_count) @@ -341,7 +323,7 @@ def test_get_liveliness_changed_status(complete_datareader): assert(fastdds.c_InstanceHandle_Unknown == status.last_publication_handle) -def test_get_matched_publication_data(complete_datareader): +def test_get_matched_publication_data(datareader): """ This test checks: - DataWriter::get_matched_publication_data @@ -349,40 +331,40 @@ def test_get_matched_publication_data(complete_datareader): pub_data = fastdds.PublicationBuiltinTopicData() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - complete_datareader.get_matched_publication_data(pub_data, ih)) + datareader.get_matched_publication_data(pub_data, ih)) -def test_get_matched_publications(complete_datareader): +def test_get_matched_publications(datareader): """ This test checks: - DataReader::get_matched_publications """ ihs = fastdds.InstanceHandleVector() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - complete_datareader.get_matched_publications(ihs)) + datareader.get_matched_publications(ihs)) -def test_get_requested_deadline_missed_status(complete_datareader): +def test_get_requested_deadline_missed_status(datareader): """ This test checks: - DataReader::get_requested_deadline_missed_status """ status = fastdds.RequestedDeadlineMissedStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.get_requested_deadline_missed_status(status)) + datareader.get_requested_deadline_missed_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) assert(fastdds.c_InstanceHandle_Unknown == status.last_instance_handle) -def test_get_requested_incompatible_qos_status(complete_datareader): +def test_get_requested_incompatible_qos_status(datareader): """ This test checks: - DataReader::get_requested_deadline_missed_status """ status = fastdds.RequestedIncompatibleQosStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.get_requested_incompatible_qos_status(status)) + datareader.get_requested_incompatible_qos_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) assert(fastdds.INVALID_QOS_POLICY_ID == status.last_policy_id) @@ -394,38 +376,38 @@ def test_get_requested_incompatible_qos_status(complete_datareader): id += 1 -def test_get_sample_lost_status(complete_datareader): +def test_get_sample_lost_status(datareader): """ This test checks: - DataReader::get_sample_lost_status """ status = fastdds.SampleLostStatus() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - complete_datareader.get_sample_lost_status(status)) + datareader.get_sample_lost_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) -def test_get_sample_rejected_status(complete_datareader): +def test_get_sample_rejected_status(datareader): """ This test checks: - DataReader::get_sample_rejected_status """ status = fastdds.SampleRejectedStatus() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - complete_datareader.get_sample_rejected_status(status)) + datareader.get_sample_rejected_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) -def test_get_subscription_matched_status(complete_datareader): +def test_get_subscription_matched_status(datareader): """ This test checks: - DataReader::get_subscription_matched_status """ status = fastdds.SubscriptionMatchedStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.get_subscription_matched_status(status)) + datareader.get_subscription_matched_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) assert(0 == status.current_count) @@ -506,56 +488,56 @@ def test_get_topicdescription(): factory.delete_participant(participant)) -def test_get_unread_count(transient_datareader_qos, complete_datareader, - complete_datawriter): +def test_get_unread_count(transient_datareader_qos, datareader, + datawriter): """ This test checks: - DataReader::get_unread_count """ - assert(0 == complete_datareader.get_unread_count()) + assert(0 == datareader.get_unread_count()) sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(complete_datawriter.write(sample)) + assert(datawriter.write(sample)) - assert(complete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) - assert(1 == complete_datareader.get_unread_count()) + assert(1 == datareader.get_unread_count()) -def test_is_sample_valid(transient_datareader_qos, complete_datareader, - complete_datawriter): +def test_is_sample_valid(transient_datareader_qos, datareader, + datawriter): """ This test checks: - DataReader::is_sample_valid """ sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(complete_datawriter.write(sample)) + assert(datawriter.write(sample)) - assert(complete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) data = test_complete.CompleteTestType() info = fastdds.SampleInfo() assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.read_next_sample(data, info)) - assert(complete_datareader.is_sample_valid(data, info)) + datareader.read_next_sample(data, info)) + assert(datareader.is_sample_valid(data, info)) assert(sample.int16_field() == data.int16_field()) -def test_lookup_instance(keyedcomplete_datareader): +def test_lookup_instance(test_keyed_type, datareader): """ This test checks: - DataReader::lookup_instance """ sample = test_complete.KeyedCompleteTestType() sample.id(3) - ih = keyedcomplete_datareader.lookup_instance(sample) + ih = datareader.lookup_instance(sample) assert(fastdds.c_InstanceHandle_Unknown == ih) -def test_read(transient_datareader_qos, complete_datareader, - complete_datawriter): +def test_read(transient_datareader_qos, datareader, + datawriter): """ This test checks: - DataReader::read @@ -564,7 +546,7 @@ def test_read(transient_datareader_qos, complete_datareader, data_seq = test_complete.CompleteTestTypeSeq() info_seq = fastdds.SampleInfoSeq() assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - complete_datareader.read( + datareader.read( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -573,11 +555,11 @@ def test_read(transient_datareader_qos, complete_datareader, sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(complete_datawriter.write(sample)) + assert(datawriter.write(sample)) - assert(complete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == complete_datareader.read( + assert(fastdds.ReturnCode_t.RETCODE_OK == datareader.read( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -586,11 +568,11 @@ def test_read(transient_datareader_qos, complete_datareader, assert(info_seq[0].valid_data is True) assert(sample.int16_field() == data_seq[0].int16_field()) assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.return_loan(data_seq, info_seq)) + datareader.return_loan(data_seq, info_seq)) -def test_read_instance(transient_datareader_qos, keyedcomplete_datareader, - keyedcomplete_datawriter): +def test_read_instance(transient_datareader_qos, test_keyed_type, + datareader, datawriter): """ This test checks: - DataReader::read_instance @@ -600,7 +582,7 @@ def test_read_instance(transient_datareader_qos, keyedcomplete_datareader, info_seq = fastdds.SampleInfoSeq() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_BAD_PARAMETER == - keyedcomplete_datareader.read_instance( + datareader.read_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -609,13 +591,13 @@ def test_read_instance(transient_datareader_qos, keyedcomplete_datareader, sample = test_complete.KeyedCompleteTestType() sample.id(255) - ih = keyedcomplete_datawriter.register_instance(sample) - assert(keyedcomplete_datawriter.write(sample, ih)) + ih = datawriter.register_instance(sample) + assert(datawriter.write(sample, ih)) - assert(keyedcomplete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) assert(fastdds.ReturnCode_t.RETCODE_OK == - keyedcomplete_datareader.read_instance( + datareader.read_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -624,11 +606,11 @@ def test_read_instance(transient_datareader_qos, keyedcomplete_datareader, assert(info_seq[0].valid_data is True) assert(sample.id() == data_seq[0].id()) assert(fastdds.ReturnCode_t.RETCODE_OK == - keyedcomplete_datareader.return_loan(data_seq, info_seq)) + datareader.return_loan(data_seq, info_seq)) -def test_read_next_instance(transient_datareader_qos, keyedcomplete_datareader, - keyedcomplete_datawriter): +def test_read_next_instance(transient_datareader_qos, test_keyed_type, + datareader, datawriter): """ This test checks: - DataReader::read_next_instance @@ -638,7 +620,7 @@ def test_read_next_instance(transient_datareader_qos, keyedcomplete_datareader, info_seq = fastdds.SampleInfoSeq() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - keyedcomplete_datareader.read_next_instance( + datareader.read_next_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -647,12 +629,12 @@ def test_read_next_instance(transient_datareader_qos, keyedcomplete_datareader, sample = test_complete.KeyedCompleteTestType() sample.id(255) - assert(keyedcomplete_datawriter.write(sample)) + assert(datawriter.write(sample)) - assert(keyedcomplete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) assert(fastdds.ReturnCode_t.RETCODE_OK == - keyedcomplete_datareader.read_next_instance( + datareader.read_next_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -661,11 +643,11 @@ def test_read_next_instance(transient_datareader_qos, keyedcomplete_datareader, assert(info_seq[0].valid_data is True) assert(sample.id() == data_seq[0].id()) assert(fastdds.ReturnCode_t.RETCODE_OK == - keyedcomplete_datareader.return_loan(data_seq, info_seq)) + datareader.return_loan(data_seq, info_seq)) -def test_read_next_sample(transient_datareader_qos, complete_datareader, - complete_datawriter): +def test_read_next_sample(transient_datareader_qos, datareader, + datawriter): """ This test checks: - DataReader::read_next_sample @@ -673,23 +655,23 @@ def test_read_next_sample(transient_datareader_qos, complete_datareader, data = test_complete.CompleteTestType() info = fastdds.SampleInfo() assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - complete_datareader.read_next_sample( + datareader.read_next_sample( data, info)) sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(complete_datawriter.write(sample)) + assert(datawriter.write(sample)) - assert(complete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.read_next_sample(data, info)) + datareader.read_next_sample(data, info)) assert(info.valid_data) assert(sample.int16_field() == data.int16_field()) -def test_take(transient_datareader_qos, complete_datareader, - complete_datawriter): +def test_take(transient_datareader_qos, datareader, + datawriter): """ This test checks: - DataReader::take @@ -698,7 +680,7 @@ def test_take(transient_datareader_qos, complete_datareader, data_seq = test_complete.CompleteTestTypeSeq() info_seq = fastdds.SampleInfoSeq() assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - complete_datareader.take( + datareader.take( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -707,11 +689,11 @@ def test_take(transient_datareader_qos, complete_datareader, sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(complete_datawriter.write(sample)) + assert(datawriter.write(sample)) - assert(complete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == complete_datareader.take( + assert(fastdds.ReturnCode_t.RETCODE_OK == datareader.take( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -720,11 +702,11 @@ def test_take(transient_datareader_qos, complete_datareader, assert(info_seq[0].valid_data is True) assert(sample.int16_field() == data_seq[0].int16_field()) assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.return_loan(data_seq, info_seq)) + datareader.return_loan(data_seq, info_seq)) -def test_take_instance(transient_datareader_qos, keyedcomplete_datareader, - keyedcomplete_datawriter): +def test_take_instance(transient_datareader_qos, test_keyed_type, + datareader, datawriter): """ This test checks: - DataReader::take_instance @@ -734,7 +716,7 @@ def test_take_instance(transient_datareader_qos, keyedcomplete_datareader, info_seq = fastdds.SampleInfoSeq() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_BAD_PARAMETER == - keyedcomplete_datareader.take_instance( + datareader.take_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -743,13 +725,13 @@ def test_take_instance(transient_datareader_qos, keyedcomplete_datareader, sample = test_complete.KeyedCompleteTestType() sample.id(255) - ih = keyedcomplete_datawriter.register_instance(sample) - assert(keyedcomplete_datawriter.write(sample, ih)) + ih = datawriter.register_instance(sample) + assert(datawriter.write(sample, ih)) - assert(keyedcomplete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) assert(fastdds.ReturnCode_t.RETCODE_OK == - keyedcomplete_datareader.take_instance( + datareader.take_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -758,11 +740,11 @@ def test_take_instance(transient_datareader_qos, keyedcomplete_datareader, assert(info_seq[0].valid_data is True) assert(sample.id() == data_seq[0].id()) assert(fastdds.ReturnCode_t.RETCODE_OK == - keyedcomplete_datareader.return_loan(data_seq, info_seq)) + datareader.return_loan(data_seq, info_seq)) -def test_take_next_instance(transient_datareader_qos, keyedcomplete_datareader, - keyedcomplete_datawriter): +def test_take_next_instance(transient_datareader_qos, test_keyed_type, + datareader, datawriter): """ This test checks: - DataReader::take_next_instance @@ -772,7 +754,7 @@ def test_take_next_instance(transient_datareader_qos, keyedcomplete_datareader, info_seq = fastdds.SampleInfoSeq() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - keyedcomplete_datareader.take_next_instance( + datareader.take_next_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -781,12 +763,12 @@ def test_take_next_instance(transient_datareader_qos, keyedcomplete_datareader, sample = test_complete.KeyedCompleteTestType() sample.id(255) - assert(keyedcomplete_datawriter.write(sample)) + assert(datawriter.write(sample)) - assert(keyedcomplete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) assert(fastdds.ReturnCode_t.RETCODE_OK == - keyedcomplete_datareader.take_next_instance( + datareader.take_next_instance( data_seq, info_seq, fastdds.LENGTH_UNLIMITED, ih, fastdds.ANY_SAMPLE_STATE, fastdds.ANY_VIEW_STATE, fastdds.ANY_INSTANCE_STATE)) @@ -795,11 +777,11 @@ def test_take_next_instance(transient_datareader_qos, keyedcomplete_datareader, assert(info_seq[0].valid_data is True) assert(sample.id() == data_seq[0].id()) assert(fastdds.ReturnCode_t.RETCODE_OK == - keyedcomplete_datareader.return_loan(data_seq, info_seq)) + datareader.return_loan(data_seq, info_seq)) -def test_take_next_sample(transient_datareader_qos, complete_datareader, - complete_datawriter): +def test_take_next_sample(transient_datareader_qos, datareader, + datawriter): """ This test checks: - DataReader::take_next_sample @@ -807,17 +789,17 @@ def test_take_next_sample(transient_datareader_qos, complete_datareader, data = test_complete.CompleteTestType() info = fastdds.SampleInfo() assert(fastdds.ReturnCode_t.RETCODE_NO_DATA == - complete_datareader.take_next_sample( + datareader.take_next_sample( data, info)) sample = test_complete.CompleteTestType() sample.int16_field(255) - assert(complete_datawriter.write(sample)) + assert(datawriter.write(sample)) - assert(complete_datareader.wait_for_unread_message( + assert(datareader.wait_for_unread_message( fastdds.Duration_t(5, 0))) assert(fastdds.ReturnCode_t.RETCODE_OK == - complete_datareader.take_next_sample(data, info)) + datareader.take_next_sample(data, info)) assert(info.valid_data) assert(sample.int16_field() == data.int16_field()) @@ -859,19 +841,19 @@ def test_get_type(): factory.delete_participant(participant)) -def test_wait_for_historical_data(complete_datareader): +def test_wait_for_historical_data(datareader): """ This test checks: - DataReader::wait_for_historical_data """ assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == - complete_datareader.wait_for_historical_data( + datareader.wait_for_historical_data( fastdds.Duration_t(0, 100))) -def test_wait_for_unread_message(complete_datareader): +def test_wait_for_unread_message(datareader): """ This test checks: - DataReader::wait_for_unread_message """ - assert(not complete_datareader.wait_for_unread_message(fastdds.Duration_t(0, 100))) + assert(not datareader.wait_for_unread_message(fastdds.Duration_t(0, 100))) From a052d14811c3f9010dfa8a3eba558db4f4c253ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Wed, 16 Mar 2022 23:11:21 +0100 Subject: [PATCH 3/8] Refs #13384. Fixtures on datarwriter api tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- fastdds_python/test/api/test_datareader.py | 87 +-- fastdds_python/test/api/test_datawriter.py | 634 +++------------------ 2 files changed, 82 insertions(+), 639 deletions(-) diff --git a/fastdds_python/test/api/test_datareader.py b/fastdds_python/test/api/test_datareader.py index 9d3eb85a..1309c548 100644 --- a/fastdds_python/test/api/test_datareader.py +++ b/fastdds_python/test/api/test_datareader.py @@ -415,78 +415,24 @@ def test_get_subscription_matched_status(datareader): assert(fastdds.c_InstanceHandle_Unknown == status.last_publication_handle) -def test_get_subscriber(): +def test_get_subscriber(subscriber, datareader): """ This test checks: - DataReader::get_subscriber """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - sub = datareader.get_subscriber() assert(sub == subscriber) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_topicdescription(): +def test_get_topicdescription(topic, datareader): """ This test checks: - DataReader::get_topicdescription """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - topic_aux = datareader.get_topicdescription() assert(topic.get_impl() == topic_aux.get_impl()) assert(topic.get_type_name() == topic_aux.get_type_name()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - def test_get_unread_count(transient_datareader_qos, datareader, datawriter): @@ -804,42 +750,15 @@ def test_take_next_sample(transient_datareader_qos, datareader, assert(sample.int16_field() == data.int16_field()) -def test_get_type(): +def test_get_type(test_type, datareader): """ This test checks: - DataReader::type """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datareader = subscriber.create_datareader( - topic, fastdds.DATAREADER_QOS_DEFAULT) - assert(datareader is not None) - test_type_aux = datareader.type() assert(test_type == test_type_aux) assert(test_type.get_type_name() == test_type_aux.get_type_name()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - def test_wait_for_historical_data(datareader): """ diff --git a/fastdds_python/test/api/test_datawriter.py b/fastdds_python/test/api/test_datawriter.py index f3b762aa..217632ce 100644 --- a/fastdds_python/test/api/test_datawriter.py +++ b/fastdds_python/test/api/test_datawriter.py @@ -1,6 +1,7 @@ import datetime import fastdds +import pytest import test_complete @@ -9,33 +10,60 @@ def __init__(self): super().__init__() -def test_assert_liveliness(): - """ - This test checks: - - DataWriter::assert_liveliness - """ +@pytest.fixture +def participant(): factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 10, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( + return factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + +@pytest.fixture +def publisher(participant): + return participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) + + +@pytest.fixture +def test_type(): + return fastdds.TypeSupport( + test_complete.CompleteTestTypePubSubType()) + + +@pytest.fixture +def test_keyed_type(test_type): + test_type.set(test_complete.KeyedCompleteTestTypePubSubType()) + + +@pytest.fixture +def topic(participant, test_type): + participant.register_type(test_type, test_type.get_type_name()) + return participant.create_topic( "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter_qos = fastdds.DataWriterQos() + + +@pytest.fixture +def datawriter_qos(): + return fastdds.DataWriterQos() + + +@pytest.fixture +def manual_liveliness_datawriter_qos(datawriter_qos): datawriter_qos.liveliness().kind = \ fastdds.MANUAL_BY_PARTICIPANT_LIVELINESS_QOS + return datawriter_qos + + +@pytest.fixture +def keep_all_datawriter_qos(datawriter_qos): + datawriter_qos.history().kind = \ + fastdds.KEEP_ALL_HISTORY_QOS + return datawriter_qos + + +@pytest.fixture +def datawriter(participant, topic, publisher, datawriter_qos): datawriter = publisher.create_datawriter(topic, datawriter_qos) - assert(datawriter is not None) - assert(fastdds.ReturnCode_t.RETCODE_OK == - datawriter.assert_liveliness()) + yield datawriter assert(fastdds.ReturnCode_t.RETCODE_OK == publisher.delete_datawriter(datawriter)) @@ -43,76 +71,39 @@ def test_assert_liveliness(): participant.delete_topic(topic)) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.delete_publisher(publisher)) + factory = fastdds.DomainParticipantFactory.get_instance() assert(fastdds.ReturnCode_t.RETCODE_OK == factory.delete_participant(participant)) -def test_clear_history(): +def test_assert_liveliness(manual_liveliness_datawriter_qos, datawriter): """ This test checks: - - DataWriter::clear_history + - DataWriter::assert_liveliness """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter_qos = fastdds.DataWriterQos() - datawriter_qos.history().kind = \ - fastdds.KEEP_ALL_HISTORY_QOS - datawriter = publisher.create_datawriter(topic, datawriter_qos) - assert(datawriter is not None) + datawriter.assert_liveliness()) - sample = test_complete.KeyedCompleteTestType() - sample.id(4) + +def test_clear_history(keep_all_datawriter_qos, datawriter): + """ + This test checks: + - DataWriter::clear_history + """ + sample = test_complete.CompleteTestType() + sample.int16_field(4) assert(datawriter.write(sample)) assert([fastdds.ReturnCode_t.RETCODE_OK, 1] == datawriter.clear_history()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_dispose(): +def test_dispose(test_keyed_type, datawriter): """ This test checks: - DataWriter::dispose - DataWriter::dispose_w_timestamp - DataWriter::unregister_instance """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - # Overload 1 sample = test_complete.KeyedCompleteTestType() sample.id(1) @@ -139,39 +130,13 @@ def test_dispose(): assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == datawriter.dispose_w_timestamp(sample, ih, timestamp)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_instance_handle(): +def test_get_instance_handle(datawriter): """ This test checks: - DataWriter::guid - DataWriter::get_instance_handle """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - guid = datawriter.guid() assert(fastdds.c_Guid_Unknown != guid) ih = datawriter.get_instance_handle() @@ -183,94 +148,31 @@ def test_get_instance_handle(): for i in range(0, 4): assert(guid.entityId.value[i] == ih.value[12+i]) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_key_value(): +def test_get_key_value(test_keyed_type, datawriter): """ This test checks: - DataWriter::get_key_value """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - sample = test_complete.KeyedCompleteTestType() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == datawriter.get_key_value(sample, ih)) assert(fastdds.c_InstanceHandle_Unknown == ih) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_sending_locators(): +def test_get_sending_locators(datawriter): """ This test checks: - DataWriter::get_sending_locators """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - locator_list = fastdds.LocatorList() assert(fastdds.ReturnCode_t.RETCODE_OK == datawriter.get_sending_locators(locator_list)) assert(0 < locator_list.size()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_set_listener(): +def test_get_set_listener(datawriter): """ This test checks: - DataWriter::get_listener @@ -279,24 +181,6 @@ def test_get_set_listener(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - # Overload 1 listener = DataWriterListener() assert(listener is not None) @@ -382,153 +266,45 @@ def test(status_mask_1, status_mask_2): fastdds.StatusMask.subscription_matched(), m) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_liveliness_lost_status(): +def test_get_liveliness_lost_status(datawriter): """ This test checks: - DataWriter::get_liveliness_lost_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - status = fastdds.LivelinessLostStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == datawriter.get_liveliness_lost_status(status)) assert(0 == status.total_count) assert(0 == status.total_count_change) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_matched_subscription_data(): +def test_get_matched_subscription_data(datawriter): """ This test checks: - DataWriter::get_matched_subscription_data """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - sub_data = fastdds.SubscriptionBuiltinTopicData() ih = fastdds.InstanceHandle_t() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == datawriter.get_matched_subscription_data(sub_data, ih)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_matched_subscriptions(): +def test_get_matched_subscriptions(datawriter): """ This test checks: - DataWriter::get_matched_subscriptions """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - ihs = fastdds.InstanceHandleVector() assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == datawriter.get_matched_subscriptions(ihs)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_offered_deadline_missed_status(): +def test_get_offered_deadline_missed_status(datawriter): """ This test checks: - DataWriter::get_offered_deadline_missed_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - status = fastdds.OfferedDeadlineMissedStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == datawriter.get_offered_deadline_missed_status(status)) @@ -536,39 +312,12 @@ def test_get_offered_deadline_missed_status(): assert(0 == status.total_count_change) assert(fastdds.c_InstanceHandle_Unknown == status.last_instance_handle) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_offered_incompatible_qos_status(): +def test_get_offered_incompatible_qos_status(datawriter): """ This test checks: - DataWriter::get_offered_deadline_missed_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - status = fastdds.OfferedIncompatibleQosStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == datawriter.get_offered_incompatible_qos_status(status)) @@ -582,39 +331,12 @@ def test_get_offered_incompatible_qos_status(): assert(id == policy.policy_id) id += 1 - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_publication_matched_status(): +def test_get_publication_matched_status(datawriter): """ This test checks: - DataWriter::get_publication_matched_status """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - status = fastdds.PublicationMatchedStatus() assert(fastdds.ReturnCode_t.RETCODE_OK == datawriter.get_publication_matched_status(status)) @@ -624,165 +346,48 @@ def test_get_publication_matched_status(): assert(0 == status.current_count_change) assert(fastdds.c_InstanceHandle_Unknown == status.last_subscription_handle) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_publisher(): +def test_get_publisher(publisher, datawriter): """ This test checks: - DataWriter::get_publisher """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - pub = datawriter.get_publisher() assert(pub == publisher) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_type(): +def test_get_type(test_type, datawriter): """ This test checks: - DataWriter::get_type """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - test_type_aux = datawriter.get_type() assert(test_type == test_type_aux) assert(test_type.get_type_name() == test_type_aux.get_type_name()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_topic(): +def test_get_topic(topic, datawriter): """ This test checks: - DataWriter::get_topic """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - topic_aux = datawriter.get_topic() assert(topic == topic_aux) assert(topic.get_type_name() == topic_aux.get_type_name()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_lookup_instance(): +def test_lookup_instance(test_keyed_type, datawriter): """ This test checks: - DataWriter::lookup_instance """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - sample = test_complete.KeyedCompleteTestType() sample.id(3) ih = datawriter.lookup_instance(sample) assert(fastdds.c_InstanceHandle_Unknown == ih) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_register_instance(): +def test_register_instance(test_keyed_type, datawriter): """ This test checks: - DataWriter::register_instance @@ -790,24 +395,6 @@ def test_register_instance(): - DataWriter::unregister_instance - DataWriter::unregister_instance_w_timestamp """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - # Overload 1 sample = test_complete.KeyedCompleteTestType() sample.id(1) @@ -837,39 +424,12 @@ def test_register_instance(): assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == datawriter.unregister_instance_w_timestamp(sample, ih, timestamp)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_wait_for_acknowledgments(): +def test_wait_for_acknowledgments(test_keyed_type, datawriter): """ This test checks: - DataWriter::wait_for_acknowledgments """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - # Overload 1 sample = test_complete.KeyedCompleteTestType() sample.id(3) @@ -884,40 +444,13 @@ def test_wait_for_acknowledgments(): datawriter.wait_for_acknowledgments( sample, ih, fastdds.Duration_t(1, 0))) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_write(): +def test_write(test_keyed_type, datawriter): """ This test checks: - DataWriter::write - DataWriter::write_w_timestamp """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport( - test_complete.KeyedCompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter = publisher.create_datawriter( - topic, fastdds.DATAWRITER_QOS_DEFAULT) - assert(datawriter is not None) - # Overload 1 sample = test_complete.KeyedCompleteTestType() assert(datawriter.write(sample)) @@ -956,12 +489,3 @@ def test_write(): assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == datawriter.write_w_timestamp(sample, ih, timestamp)) assert(fastdds.c_InstanceHandle_Unknown == ih) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) From f0b3545ad14739fff3cc0083b22a8dc6a3971e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Thu, 17 Mar 2022 07:22:12 +0100 Subject: [PATCH 4/8] Refs #13384. Add fixtures on subscriber api tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- fastdds_python/test/api/test_subscriber.py | 229 +++++---------------- 1 file changed, 53 insertions(+), 176 deletions(-) diff --git a/fastdds_python/test/api/test_subscriber.py b/fastdds_python/test/api/test_subscriber.py index 07c65718..79745303 100644 --- a/fastdds_python/test/api/test_subscriber.py +++ b/fastdds_python/test/api/test_subscriber.py @@ -1,4 +1,5 @@ import fastdds +import pytest import test_complete @@ -12,31 +13,60 @@ def __init__(self): super().__init__() -def test_access(): +@pytest.fixture +def participant_qos(): + return fastdds.DomainParticipantQos() + + +@pytest.fixture +def not_autoenable_participant_qos(participant_qos): + participant_qos.entity_factory().autoenable_created_entities = False + return participant_qos + + +@pytest.fixture +def participant(participant_qos): + factory = fastdds.DomainParticipantFactory.get_instance() + return factory.create_participant(0, participant_qos) + + +@pytest.fixture +def subscriber(participant, topic): + subscriber = participant.create_subscriber( + fastdds.SUBSCRIBER_QOS_DEFAULT) + + yield subscriber + + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_subscriber(subscriber)) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_topic(topic)) + factory = fastdds.DomainParticipantFactory.get_instance() + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + + +@pytest.fixture +def topic(participant): + test_type = fastdds.TypeSupport( + test_complete.CompleteTestTypePubSubType()) + participant.register_type(test_type, test_type.get_type_name()) + return participant.create_topic( + "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) + + +def test_access(subscriber): """ This test checks: - ::resume_publications """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == subscriber.begin_access()) assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == subscriber.end_access()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_create_and_delete_datareader(): +def test_create_and_delete_datareader(topic, subscriber): """ This test checks: - Subscriber::create_datareader @@ -45,20 +75,6 @@ def test_create_and_delete_datareader(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - # Overload 1 - Success - topic = participant.create_topic( - "Complete", "CompleteTestType", fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) listener = DataReaderListener() assert(listener is not None) @@ -160,32 +176,12 @@ def test(status_mask_1, status_mask_2, listnr=None): m, listener) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_deleted_contained_entities(): +def test_deleted_contained_entities(participant, topic, subscriber): """ This test checks: - Subscriber::delete_contained_entities """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", "CompleteTestType", fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) datareader = subscriber.create_datareader( topic, fastdds.DATAREADER_QOS_DEFAULT) assert(datareader is not None) @@ -199,59 +195,25 @@ def test_deleted_contained_entities(): assert(subscriber.has_datareaders() is False) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_enable(): +def test_enable(not_autoenable_participant_qos, subscriber): """ This test checks: - Subscriber::enable - Subscriber::is_enabled """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - qos = fastdds.DomainParticipantQos() - qos.entity_factory().autoenable_created_entities = False - participant = factory.create_participant(0, qos) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - assert(not subscriber.is_enabled()) assert(fastdds.ReturnCode_t.RETCODE_OK == subscriber.enable()) assert(subscriber.is_enabled()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_datareaders(): +def test_get_datareaders(topic, subscriber): """ This test checks: - Subscriber::get_datareaders - Subscriber::has_datareaders """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", "CompleteTestType", fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) datareader = subscriber.create_datareader( topic, fastdds.DATAREADER_QOS_DEFAULT) assert(datareader is not None) @@ -264,28 +226,14 @@ def test_get_datareaders(): assert(fastdds.ReturnCode_t.RETCODE_OK == subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) -def test_get_instance_handle(): +def test_get_instance_handle(participant, subscriber): """ This test checks: - Subscriber::get_instance_handle - Subscriber::guid """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - ih = subscriber.get_instance_handle() assert(ih is not None) assert(ih.isDefined()) @@ -298,53 +246,24 @@ def test_get_instance_handle(): for i in range(0, 12): assert(guid.guidPrefix.value[i] == ih.value[i]) - # for i in range(0, 4): - # assert(guid.entityId.value[i] == ih.value[12+i]) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - - -def test_get_participant(): +def test_get_participant(participant, subscriber): """ This test checks: - Subscriber::get_participant """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - participant2 = subscriber.get_participant() assert(participant2 is not None) assert(participant == participant2) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_set_qos(): +def test_get_set_qos(subscriber): """ This test checks: - Subscriber::get_qos - Subscriber::set_qos """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) qos = fastdds.SubscriberQos() - subscriber = participant.create_subscriber(qos) - assert(subscriber is not None) - qos.partition().push_back('PartitionTest') qos.partition().push_back('PartitionTest2') assert(fastdds.ReturnCode_t.RETCODE_OK == @@ -354,17 +273,8 @@ def test_get_set_qos(): assert(fastdds.ReturnCode_t.RETCODE_OK == subscriber.get_qos(qos2)) - assert(2 == len(qos.partition())) - assert('PartitionTest' == qos.partition()[0]) - assert('PartitionTest2' == qos.partition()[1]) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_set_listener(): +def test_get_set_listener(subscriber): """ This test checks: - Publisher::get_listener @@ -373,14 +283,6 @@ def test_get_set_listener(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - # Overload 1 listener = SubscriberListener() assert(listener is not None) @@ -466,31 +368,12 @@ def test(status_mask_1, status_mask_2): fastdds.StatusMask.subscription_matched(), m) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_lookup_datareader(): +def test_lookup_datareader(topic, subscriber): """ This test checks: - subscriber::lookup_datareader """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - # Overload 1 - Success - topic = participant.create_topic( - "Complete", "CompleteTestType", fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) datareader = subscriber.create_datareader( topic, fastdds.DATAREADER_QOS_DEFAULT) assert(datareader is not None) @@ -501,9 +384,3 @@ def test_lookup_datareader(): assert(fastdds.ReturnCode_t.RETCODE_OK == subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) From faa13e0679b931b101aec2e052a730b3162fc244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Thu, 17 Mar 2022 07:31:25 +0100 Subject: [PATCH 5/8] Refs #13384. Add fixtures to publisher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- fastdds_python/test/api/test_publisher.py | 279 +++++----------------- 1 file changed, 54 insertions(+), 225 deletions(-) diff --git a/fastdds_python/test/api/test_publisher.py b/fastdds_python/test/api/test_publisher.py index 587dadc7..02df14a8 100644 --- a/fastdds_python/test/api/test_publisher.py +++ b/fastdds_python/test/api/test_publisher.py @@ -1,4 +1,5 @@ import fastdds +import pytest import test_complete @@ -12,32 +13,61 @@ def __init__(self): super().__init__() -def test_coherent_changes(): +@pytest.fixture +def participant_qos(): + return fastdds.DomainParticipantQos() + + +@pytest.fixture +def not_autoenable_participant_qos(participant_qos): + participant_qos.entity_factory().autoenable_created_entities = False + return participant_qos + + +@pytest.fixture +def participant(participant_qos): + factory = fastdds.DomainParticipantFactory.get_instance() + return factory.create_participant(0, participant_qos) + + +@pytest.fixture +def publisher(participant, topic): + publisher = participant.create_publisher( + fastdds.PUBLISHER_QOS_DEFAULT) + + yield publisher + + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_publisher(publisher)) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_topic(topic)) + factory = fastdds.DomainParticipantFactory.get_instance() + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + + +@pytest.fixture +def topic(participant): + test_type = fastdds.TypeSupport( + test_complete.CompleteTestTypePubSubType()) + participant.register_type(test_type, test_type.get_type_name()) + return participant.create_topic( + "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) + + +def test_coherent_changes(publisher): """ This test checks: - Publisher::begin_coherent_changes - Publisher::end_coherent_changes """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == publisher.begin_coherent_changes()) assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == publisher.end_coherent_changes()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_create_and_delete_datawriter(): +def test_create_and_delete_datawriter(topic, publisher): """ This test checks: - Publisher::create_datawriter @@ -46,20 +76,6 @@ def test_create_and_delete_datawriter(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - # Overload 1 - Success - topic = participant.create_topic( - "Complete", "CompleteTestType", fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) listener = DataWriterListener() assert(listener is not None) @@ -161,32 +177,12 @@ def test(status_mask_1, status_mask_2, listnr=None): m, listener) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_deleted_contained_entities(): +def test_deleted_contained_entities(participant, topic, publisher): """ This test checks: - Publisher::delete_contained_entities """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", "CompleteTestType", fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) datawriter = publisher.create_datawriter( topic, fastdds.DATAWRITER_QOS_DEFAULT) assert(datawriter is not None) @@ -199,59 +195,25 @@ def test_deleted_contained_entities(): publisher.delete_contained_entities()) assert(publisher.has_datawriters() is False) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_enable(): +def test_enable(not_autoenable_participant_qos, publisher): """ This test checks: - Publisher::enable - Publisher::is_enabled """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - qos = fastdds.DomainParticipantQos() - qos.entity_factory().autoenable_created_entities = False - participant = factory.create_participant(0, qos) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - assert(not publisher.is_enabled()) assert(fastdds.ReturnCode_t.RETCODE_OK == publisher.enable()) assert(publisher.is_enabled()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_datawriters(): +def test_get_datawriters(topic, publisher): """ This test checks: - Publisher::get_datawriters - Publisher::has_datawriters """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", "CompleteTestType", fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) datawriter = publisher.create_datawriter( topic, fastdds.DATAWRITER_QOS_DEFAULT) assert(datawriter is not None) @@ -264,28 +226,14 @@ def test_get_datawriters(): assert(fastdds.ReturnCode_t.RETCODE_OK == publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) -def test_get_instance_handle(): +def test_get_instance_handle(participant, publisher): """ This test checks: - Publisher::get_instance_handle - Publisher::guid """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - ih = publisher.get_instance_handle() assert(ih is not None) assert(ih.isDefined()) @@ -298,52 +246,24 @@ def test_get_instance_handle(): for i in range(0, 12): assert(guid.guidPrefix.value[i] == ih.value[i]) - # for i in range(0, 4): - # assert(guid.entityId.value[i] == ih.value[12+i]) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_participant(): +def test_get_participant(participant, publisher): """ This test checks: - Publisher::get_participant """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - participant2 = publisher.get_participant() assert(participant2 is not None) assert(participant == participant2) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_set_qos(): +def test_get_set_qos(publisher): """ This test checks: - Publisher::get_qos - Publisher::set_qos """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) qos = fastdds.PublisherQos() - publisher = participant.create_publisher(qos) - assert(publisher is not None) qos.partition().push_back('PartitionTest') qos.partition().push_back('PartitionTest2') @@ -358,13 +278,8 @@ def test_get_set_qos(): assert('PartitionTest' == qos.partition()[0]) assert('PartitionTest2' == qos.partition()[1]) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_set_listener(): +def test_get_set_listener(publisher): """ This test checks: - Publisher::get_listener @@ -373,14 +288,6 @@ def test_get_set_listener(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - # Overload 1 listener = PublisherListener() assert(listener is not None) @@ -466,31 +373,12 @@ def test(status_mask_1, status_mask_2): fastdds.StatusMask.subscription_matched(), m) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_lookup_datawriter(): +def test_lookup_datawriter(topic, publisher): """ This test checks: - Publisher::lookup_datawriter """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - # Overload 1 - Success - topic = participant.create_topic( - "Complete", "CompleteTestType", fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) datawriter = publisher.create_datawriter( topic, fastdds.DATAWRITER_QOS_DEFAULT) assert(datawriter is not None) @@ -501,12 +389,6 @@ def test_lookup_datawriter(): assert(fastdds.ReturnCode_t.RETCODE_OK == publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) def test_suspend_publications(): @@ -534,64 +416,11 @@ def test_suspend_publications(): factory.delete_participant(participant)) -def test_wait_for_acknowlegments(): +def test_wait_for_acknowlegments(publisher): """ This test checks: - Publisher::wait_for_acknowledgments """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - assert(fastdds.ReturnCode_t.RETCODE_OK == publisher.wait_for_acknowledgments(fastdds.Duration_t(3, 0))) # TODO Test a timeout - - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - - -# -# /** -# * This operation creates a DataWriter. The returned DataWriter will be attached and belongs to the Publisher. -# * -# * @param topic Topic the DataWriter will be listening -# * @param profile_name DataWriter profile name. -# * @param listener Pointer to the listener (default: nullptr). -# * @param mask StatusMask that holds statuses the listener responds to (default: all). -# * @return Pointer to the created DataWriter. nullptr if failed. -# */ -# RTPS_DllAPI DataWriter* create_datawriter_with_profile( -# Topic* topic, -# const std::string& profile_name, -# DataWriterListener* listener = nullptr, -# const StatusMask& mask = StatusMask::all()); -# -# -# /** -# * @brief Copies TopicQos into the corresponding DataWriterQos -# * -# * @param[out] writer_qos -# * @param[in] topic_qos -# * @return RETCODE_OK if successful, an error code otherwise -# */ -# RTPS_DllAPI ReturnCode_t copy_from_topic_qos( -# fastdds::dds::DataWriterQos& writer_qos, -# const fastdds::dds::TopicQos& topic_qos) const; -# -# /** -# * Fills the DataWriterQos with the values of the XML profile. -# * -# * @param profile_name DataWriter profile name. -# * @param qos DataWriterQos object where the qos is returned. -# * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. -# */ -# RTPS_DllAPI ReturnCode_t get_datawriter_qos_from_profile( -# const std::string& profile_name, -# DataWriterQos& qos) const; From 5aef1fe8cad807c28544e4eb32a4dc0d7b961b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Thu, 17 Mar 2022 08:00:53 +0100 Subject: [PATCH 6/8] Refs #13384. Add fixtures to domainparticipant api tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- fastdds_python/test/api/test_datareader.py | 3 + fastdds_python/test/api/test_datawriter.py | 5 +- .../test/api/test_domainparticipant.py | 639 ++---------------- fastdds_python/test/api/test_publisher.py | 3 + fastdds_python/test/api/test_subscriber.py | 3 + 5 files changed, 68 insertions(+), 585 deletions(-) diff --git a/fastdds_python/test/api/test_datareader.py b/fastdds_python/test/api/test_datareader.py index 1309c548..6ee1ea05 100644 --- a/fastdds_python/test/api/test_datareader.py +++ b/fastdds_python/test/api/test_datareader.py @@ -218,6 +218,7 @@ def test_get_set_listener(datareader): assert(datareader.get_listener() == listener) assert(fastdds.StatusMask.all() == datareader.get_status_mask()) + datareader.set_listener(None) def test(status_mask_1, status_mask_2): """ @@ -229,12 +230,14 @@ def test(status_mask_1, status_mask_2): datareader.set_listener(listener, status_mask_1)) assert(datareader.get_listener() == listener) assert(status_mask_1 == datareader.get_status_mask()) + datareader.set_listener(None) listener = DataReaderListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == datareader.set_listener(listener, status_mask_2)) assert(datareader.get_listener() == listener) assert(status_mask_2 == datareader.get_status_mask()) + datareader.set_listener(None) # Overload 2: Different status masks test(fastdds.StatusMask.all(), fastdds.StatusMask_all()) diff --git a/fastdds_python/test/api/test_datawriter.py b/fastdds_python/test/api/test_datawriter.py index 217632ce..7b6d8907 100644 --- a/fastdds_python/test/api/test_datawriter.py +++ b/fastdds_python/test/api/test_datawriter.py @@ -188,6 +188,7 @@ def test_get_set_listener(datawriter): datawriter.set_listener(listener)) assert(datawriter.get_listener() == listener) assert(fastdds.StatusMask.all() == datawriter.get_status_mask()) + datawriter.set_listener(None) def test(status_mask_1, status_mask_2): """ @@ -196,15 +197,17 @@ def test(status_mask_1, status_mask_2): listener = DataWriterListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == - datawriter.set_listener(listener, status_mask_1)) + datawriter.set_listener(listener, status_mask_1)) assert(datawriter.get_listener() == listener) assert(status_mask_1 == datawriter.get_status_mask()) + datawriter.set_listener(None) listener = DataWriterListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == datawriter.set_listener(listener, status_mask_2)) assert(datawriter.get_listener() == listener) assert(status_mask_2 == datawriter.get_status_mask()) + datawriter.set_listener(None) # Overload 2: Different status masks test(fastdds.StatusMask.all(), fastdds.StatusMask_all()) diff --git a/fastdds_python/test/api/test_domainparticipant.py b/fastdds_python/test/api/test_domainparticipant.py index 79a557f0..16891326 100644 --- a/fastdds_python/test/api/test_domainparticipant.py +++ b/fastdds_python/test/api/test_domainparticipant.py @@ -1,4 +1,5 @@ import fastdds +import pytest import test_complete @@ -22,17 +23,38 @@ def __init__(self): super().__init__() -def test_contains_entity(): +@pytest.fixture +def not_autoenable_factory(): + factory = fastdds.DomainParticipantFactory.get_instance() + factory_qos = fastdds.DomainParticipantFactoryQos() + factory.get_qos(factory_qos) + factory_qos.entity_factory().autoenable_created_entities = False + factory.set_qos(factory_qos) + return factory + + +@pytest.fixture +def participant_qos(): + return fastdds.DomainParticipantQos() + + +@pytest.fixture +def testname_participant_qos(participant_qos): + participant_qos.name('TestName') + return participant_qos + + +@pytest.fixture +def participant(participant_qos): + factory = fastdds.DomainParticipantFactory.get_instance() + return factory.create_participant(0, participant_qos) + + +def test_contains_entity(participant): """ This test checks: - DomainParticipant::contains_entity """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) assert(publisher is not None) @@ -42,11 +64,9 @@ def test_contains_entity(): assert(fastdds.ReturnCode_t.RETCODE_OK == participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) -def test_create_and_delete_publisher(): +def test_create_and_delete_publisher(participant): """ This test checks: - DomainParticipant::create_publisher @@ -55,11 +75,6 @@ def test_create_and_delete_publisher(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) listener = PublisherListener() assert(listener is not None) @@ -160,11 +175,8 @@ def test(status_mask_1, status_mask_2, listnr=None): m, listener) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_create_and_delete_subscriber(): +def test_create_and_delete_subscriber(participant): """ This test checks: - DomainParticipant::create_subscriber @@ -173,11 +185,6 @@ def test_create_and_delete_subscriber(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) listener = SubscriberListener() assert(listener is not None) @@ -278,11 +285,8 @@ def test(status_mask_1, status_mask_2, listnr=None): m, listener) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_create_and_delete_topic(): +def test_create_and_delete_topic(participant): """ This test checks: - DomainParticipant::create_topic @@ -291,11 +295,6 @@ def test_create_and_delete_topic(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) listener = TopicListener() assert(listener is not None) @@ -409,17 +408,8 @@ def test(status_mask_1, status_mask_2, listnr=None): m, listener) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - - -def test_delete_contained_entities(): - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) +def test_delete_contained_entities(participant): publisher = participant.create_publisher( fastdds.PUBLISHER_QOS_DEFAULT) assert(publisher is not None) @@ -434,57 +424,35 @@ def test_delete_contained_entities(): assert(topic is not None) # Cannot delete participant without deleting its contained entities + factory = fastdds.DomainParticipantFactory.get_instance() assert(fastdds.ReturnCode_t.RETCODE_PRECONDITION_NOT_MET == factory.delete_participant(participant)) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.delete_contained_entities()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_enable(): +def test_enable(not_autoenable_factory, participant): """ This test checks: - DomainParticipant::enable - DomainParticipant::is_enabled """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - factory_qos = fastdds.DomainParticipantFactoryQos() - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.get_qos(factory_qos)) - factory_qos.entity_factory().autoenable_created_entities = False - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.set_qos(factory_qos)) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - assert(not participant.is_enabled()) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.enable()) assert(participant.is_enabled()) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) + factory_qos = fastdds.DomainParticipantFactoryQos() factory_qos.entity_factory().autoenable_created_entities = True assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.set_qos(factory_qos)) + not_autoenable_factory.set_qos(factory_qos)) -def test_find_topic(): +def test_find_topic(participant): """ This test checks: - DomainParticipant::find_topic """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.register_type(test_type, test_type.get_type_name())) @@ -502,40 +470,25 @@ def test_find_topic(): assert(fastdds.ReturnCode_t.RETCODE_OK == participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) -def test_get_builtin_subscriber(): +def test_get_builtin_subscriber(participant): """ This test checks: - DomainParticipant::get_builtin_subscriber """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - builtin_subscriber = participant.get_builtin_subscriber() assert(builtin_subscriber is None) # assert(builtin_subscriber.is_enabled()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_discovered_participants(): +def test_get_discovered_participants(participant): """ This test checks: - DomainParticipant::get_discovered_participants - DomainParticipant::get_discovered_participant_data """ factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) participant2 = factory.create_participant( 0, fastdds.PARTICIPANT_QOS_DEFAULT) assert(participant2 is not None) @@ -544,6 +497,9 @@ def test_get_discovered_participants(): assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == participant.get_discovered_participants(ihs)) + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant2)) + def test_get_domain_id(): """ @@ -562,18 +518,12 @@ def test_get_domain_id(): factory.delete_participant(participant)) -def test_get_instance_handle(): +def test_get_instance_handle(participant): """ This test checks: - DomainParticipant::get_instance_handle - DomainParticipant::guid """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - ih = participant.get_instance_handle() assert(ih is not None) # assert(ih.isDefined()) @@ -591,11 +541,8 @@ def test_get_instance_handle(): for i in range(0, 4): assert(guid.entityId.value[i] == ih.value[12+i]) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_set_listener(): +def test_get_set_listener(participant): """ This test checks: - DomainParticipant::get_listener @@ -604,12 +551,6 @@ def test_get_set_listener(): - StatusMask::operator == - StatusMask::operator << """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 7, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - # Overload 1 listener = DomainParticipantListener() assert(listener is not None) @@ -617,6 +558,7 @@ def test_get_set_listener(): participant.set_listener(listener)) assert(participant.get_listener() == listener) assert(fastdds.StatusMask.all() == participant.get_status_mask()) + participant.set_listener(None) def test(status_mask_1, status_mask_2): """ @@ -628,12 +570,14 @@ def test(status_mask_1, status_mask_2): participant.set_listener(listener, status_mask_1)) assert(participant.get_listener() == listener) assert(status_mask_1 == participant.get_status_mask()) + participant.set_listener(None) listener = DomainParticipantListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.set_listener(listener, status_mask_2)) assert(participant.get_listener() == listener) assert(status_mask_2 == participant.get_status_mask()) + participant.set_listener(None) # Overload 3: Different status masks test(fastdds.StatusMask.all(), fastdds.StatusMask_all()) @@ -695,41 +639,23 @@ def test(status_mask_1, status_mask_2): fastdds.StatusMask.subscription_matched(), m) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_partitipant_names(): +def test_get_partitipant_names(testname_participant_qos, participant): """ This test checks: - DomainParticipant::get_participant_names """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - qos = fastdds.DomainParticipantQos() - qos.name('TestName') - participant = factory.create_participant(0, qos) - assert(participant is not None) - names = participant.get_participant_names() assert('TestName' == names[0]) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_get_set_qos(): +def test_get_set_qos(participant): """ This test checks: - DomainParticipant::get_qos - DomainParticipant::set_qos """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) qos = fastdds.DomainParticipantQos() - participant = factory.create_participant(0, qos) - assert(participant is not None) - assert(fastdds.ReturnCode_t.RETCODE_OK == participant.get_qos(qos)) qos.user_data().push_back(1) qos.user_data().push_back(2) @@ -745,101 +671,56 @@ def test_get_set_qos(): assert(1 == qos2.user_data()[0]) assert(2 == qos2.user_data()[1]) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_ignore_participant(): +def test_ignore_participant(participant): """ This test checks: - DomainParticipant::ignore_participant """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - ih = fastdds.InstanceHandle_t() ih.value = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == participant.ignore_participant(ih)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_ignore_publication(): +def test_ignore_publication(participant): """ This test checks: - DomainParticipant::ignore_publication """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - ih = fastdds.InstanceHandle_t() ih.value = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == participant.ignore_publication(ih)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_ignore_subscription(): +def test_ignore_subscription(participant): """ This test checks: - DomainParticipant::ignore_subscription """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - ih = fastdds.InstanceHandle_t() ih.value = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == participant.ignore_subscription(ih)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_ignore_topic(): +def test_ignore_topic(participant): """ This test checks: - DomainParticipant::ignore_topic """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - ih = fastdds.InstanceHandle_t() ih.value = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == participant.ignore_topic(ih)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - -def test_lookup_topicdescription(): +def test_lookup_topicdescription(participant): """ This test checks: - DomainParticipant::lookup_topicdescription """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) assert(fastdds.ReturnCode_t.RETCODE_OK == participant.register_type(test_type, test_type.get_type_name())) @@ -855,413 +736,3 @@ def test_lookup_topicdescription(): assert(fastdds.ReturnCode_t.RETCODE_OK == participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - - - -# -# -# /** -# * Create a Publisher in this Participant. -# * -# * @param profile_name Publisher profile name. -# * @param listener Pointer to the listener (default: nullptr) -# * @param mask StatusMask that holds statuses the listener responds to (default: all) -# * @return Pointer to the created Publisher. -# */ -# RTPS_DllAPI Publisher* create_publisher_with_profile( -# const std::string& profile_name, -# PublisherListener* listener = nullptr, -# const StatusMask& mask = StatusMask::all()); -# -# /** -# * Create a Subscriber in this Participant. -# * -# * @param profile_name Subscriber profile name. -# * @param listener Pointer to the listener (default: nullptr) -# * @param mask StatusMask that holds statuses the listener responds to (default: all) -# * @return Pointer to the created Subscriber. -# */ -# RTPS_DllAPI Subscriber* create_subscriber_with_profile( -# const std::string& profile_name, -# SubscriberListener* listener = nullptr, -# const StatusMask& mask = StatusMask::all()); -# -# -# * Create a Topic in this Participant. -# * -# * @param topic_name Name of the Topic. -# * @param type_name Data type of the Topic. -# * @param profile_name Topic profile name. -# * @param listener Pointer to the listener (default: nullptr) -# * @param mask StatusMask that holds statuses the listener responds to (default: all) -# * @return Pointer to the created Topic. -# */ -# RTPS_DllAPI Topic* create_topic_with_profile( -# const std::string& topic_name, -# const std::string& type_name, -# const std::string& profile_name, -# TopicListener* listener = nullptr, -# const StatusMask& mask = StatusMask::all()); -# -# /** -# * Create a ContentFilteredTopic in this Participant. -# * -# * @param name Name of the ContentFilteredTopic -# * @param related_topic Related Topic to being subscribed -# * @param filter_expression Logic expression to create filter -# * @param expression_parameters Parameters to filter content -# * @return Pointer to the created ContentFilteredTopic. -# * @return nullptr if @c related_topic does not belong to this participant. -# * @return nullptr if a topic with the specified @c name has already been created. -# * @return nullptr if a filter cannot be created with the specified @c filter_expression and -# * @c expression_parameters. -# */ -# RTPS_DllAPI ContentFilteredTopic* create_contentfilteredtopic( -# const std::string& name, -# Topic* related_topic, -# const std::string& filter_expression, -# const std::vector& expression_parameters); -# -# /** -# * Create a ContentFilteredTopic in this Participant using a custom filter. -# * -# * @param name Name of the ContentFilteredTopic -# * @param related_topic Related Topic to being subscribed -# * @param filter_expression Logic expression to create filter -# * @param expression_parameters Parameters to filter content -# * @param filter_class_name Name of the filter class to use -# * -# * @return Pointer to the created ContentFilteredTopic. -# * @return nullptr if @c related_topic does not belong to this participant. -# * @return nullptr if a topic with the specified @c name has already been created. -# * @return nullptr if a filter cannot be created with the specified @c filter_expression and -# * @c expression_parameters. -# * @return nullptr if the specified @c filter_class_name has not been registered. -# */ -# RTPS_DllAPI ContentFilteredTopic* create_contentfilteredtopic( -# const std::string& name, -# Topic* related_topic, -# const std::string& filter_expression, -# const std::vector& expression_parameters, -# const char* filter_class_name); -# -# /** -# * Deletes an existing ContentFilteredTopic. -# * -# * @param a_contentfilteredtopic ContentFilteredTopic to be deleted -# * @return RETCODE_BAD_PARAMETER if the topic passed is a nullptr, RETCODE_PRECONDITION_NOT_MET if the topic does not belong to -# * this participant or if it is referenced by any entity and RETCODE_OK if the ContentFilteredTopic was deleted. -# */ -# RTPS_DllAPI ReturnCode_t delete_contentfilteredtopic( -# const ContentFilteredTopic* a_contentfilteredtopic); -# -# /** -# * Create a MultiTopic in this Participant. -# * -# * @param name Name of the MultiTopic -# * @param type_name Result type of the MultiTopic -# * @param subscription_expression Logic expression to combine filter -# * @param expression_parameters Parameters to subscription content -# * @return Pointer to the created ContentFilteredTopic, nullptr in error case -# */ -# RTPS_DllAPI MultiTopic* create_multitopic( -# const std::string& name, -# const std::string& type_name, -# const std::string& subscription_expression, -# const std::vector& expression_parameters); -# -# /** -# * Deletes an existing MultiTopic. -# * -# * @param a_multitopic MultiTopic to be deleted -# * @return RETCODE_BAD_PARAMETER if the topic passed is a nullptr, RETCODE_PRECONDITION_NOT_MET if the topic does not belong to -# * this participant or if it is referenced by any entity and RETCODE_OK if the Topic was deleted. -# */ -# RTPS_DllAPI ReturnCode_t delete_multitopic( -# const MultiTopic* a_multitopic); -# -# /** -# * This operation manually asserts the liveliness of the DomainParticipant. -# * This is used in combination with the LIVELINESS QoS policy to indicate to the Service that the entity -# * remains active. -# * -# * This operation needs to only be used if the DomainParticipant contains DataWriter entities with -# * the LIVELINESS set to MANUAL_BY_PARTICIPANT and it only affects the liveliness of those DataWriter entities. -# * Otherwise, it has no effect. -# * -# * @note Writing data via the write operation on a DataWriter asserts liveliness on the DataWriter itself and its -# * DomainParticipant. Consequently the use of assert_liveliness is only needed if the application is not -# * writing data regularly. -# * -# * @return RETCODE_OK if the liveliness was asserted, RETCODE_ERROR otherwise. -# */ -# RTPS_DllAPI ReturnCode_t assert_liveliness(); -# -# /** -# * Fills the PublisherQos with the values of the XML profile. -# * -# * @param profile_name Publisher profile name. -# * @param qos PublisherQos object where the qos is returned. -# * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. -# */ -# RTPS_DllAPI ReturnCode_t get_publisher_qos_from_profile( -# const std::string& profile_name, -# PublisherQos& qos) const; -# -# -# /** -# * Fills the SubscriberQos with the values of the XML profile. -# * -# * @param profile_name Subscriber profile name. -# * @param qos SubscriberQos object where the qos is returned. -# * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. -# */ -# RTPS_DllAPI ReturnCode_t get_subscriber_qos_from_profile( -# const std::string& profile_name, -# SubscriberQos& qos) const; -# -# -# /** -# * Fills the TopicQos with the values of the XML profile. -# * -# * @param profile_name Topic profile name. -# * @param qos TopicQos object where the qos is returned. -# * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. -# */ -# RTPS_DllAPI ReturnCode_t get_topic_qos_from_profile( -# const std::string& profile_name, -# TopicQos& qos) const; -# -# /** -# * Retrieves the list of topics that have been discovered in the domain and are not "ignored". -# * -# * @param[out] topic_handles Reference to the vector where discovered topics will be returned -# * @return RETCODE_OK if everything correct, error code otherwise -# */ -# RTPS_DllAPI ReturnCode_t get_discovered_topics( -# std::vector& topic_handles) const; -# -# /** -# * Retrieves the Topic data of a discovered not ignored topic. -# * -# * @param[out] topic_data Reference to the TopicBuiltinTopicData object to return the data -# * @param topic_handle InstanceHandle of Topic to retrieve the data from -# * @return RETCODE_OK if everything correct, PRECONDITION_NOT_MET if topic does not exist -# */ -# RTPS_DllAPI ReturnCode_t get_discovered_topic_data( -# builtin::TopicBuiltinTopicData& topic_data, -# const InstanceHandle_t& topic_handle) const; -# -# /** -# * This operation checks whether or not the given handle represents an Entity that was created from the -# * DomainParticipant. -# * -# * @param a_handle InstanceHandle of the entity to look for. -# * @param recursive The containment applies recursively. That is, it applies both to entities -# * (TopicDescription, Publisher, or Subscriber) created directly using the DomainParticipant as well as -# * entities created using a contained Publisher, or Subscriber as the factory, and so forth. (default: true) -# * @return True if entity is contained. False otherwise. -# */ -# RTPS_DllAPI bool contains_entity( -# const InstanceHandle_t& a_handle, -# bool recursive = true) const; -# -# /** -# * This operation returns the current value of the time that the service uses to time-stamp data-writes -# * and to set the reception-timestamp for the data-updates it receives. -# * -# * @param current_time Time_t reference where the current time is returned -# * @return RETCODE_OK -# */ -# RTPS_DllAPI ReturnCode_t get_current_time( -# fastrtps::Time_t& current_time) const; -# -# // DomainParticipant methods specific from Fast-DDS -# -# /** -# * Register a type in this participant. -# * -# * @param type TypeSupport. -# * @param type_name The name that will be used to identify the Type. -# * @return RETCODE_BAD_PARAMETER if the size of the name is 0, RERCODE_PRECONDITION_NOT_MET if there is another TypeSupport -# * with the same name and RETCODE_OK if it is correctly registered. -# */ -# RTPS_DllAPI ReturnCode_t register_type( -# TypeSupport type, -# const std::string& type_name); -# -# /** -# * Register a type in this participant. -# * -# * @param type TypeSupport. -# * @return RETCODE_BAD_PARAMETER if the size of the name is 0, RERCODE_PRECONDITION_NOT_MET if there is another TypeSupport -# * with the same name and RETCODE_OK if it is correctly registered. -# */ -# RTPS_DllAPI ReturnCode_t register_type( -# TypeSupport type); -# -# /** -# * Unregister a type in this participant. -# * -# * @param typeName Name of the type -# * @return RETCODE_BAD_PARAMETER if the size of the name is 0, RERCODE_PRECONDITION_NOT_MET if there are entities using that -# * TypeSupport and RETCODE_OK if it is correctly unregistered. -# */ -# RTPS_DllAPI ReturnCode_t unregister_type( -# const std::string& typeName); -# -# /** -# * This method gives access to a registered type based on its name. -# * -# * @param type_name Name of the type -# * @return TypeSupport corresponding to the type_name -# */ -# RTPS_DllAPI TypeSupport find_type( -# const std::string& type_name) const; -# -# /** -# * @brief Getter for the participant names -# * -# * @return Vector with the names -# */ -# RTPS_DllAPI std::vector get_participant_names() const; -# -# /** -# * This method can be used when using a StaticEndpointDiscovery mechanism different that the one -# * included in FastRTPS, for example when communicating with other implementations. -# * It indicates the Participant that an Endpoint from the XML has been discovered and -# * should be activated. -# * -# * @param partguid Participant GUID_t. -# * @param userId User defined ID as shown in the XML file. -# * @param kind EndpointKind (WRITER or READER) -# * @return True if correctly found and activated. -# */ -# RTPS_DllAPI bool new_remote_endpoint_discovered( -# const fastrtps::rtps::GUID_t& partguid, -# uint16_t userId, -# fastrtps::rtps::EndpointKind_t kind); -# -# /** -# * @brief Getter for the resource event -# * -# * @return A reference to the resource event -# */ -# RTPS_DllAPI fastrtps::rtps::ResourceEvent& get_resource_event() const; -# -# /** -# * When a DomainParticipant receives an incomplete list of TypeIdentifiers in a -# * PublicationBuiltinTopicData or SubscriptionBuiltinTopicData, it may request the additional type -# * dependencies by invoking the getTypeDependencies operation. -# * -# * @param in TypeIdentifier sequence -# * @return SampleIdentity -# */ -# RTPS_DllAPI fastrtps::rtps::SampleIdentity get_type_dependencies( -# const fastrtps::types::TypeIdentifierSeq& in) const; -# -# /** -# * A DomainParticipant may invoke the operation getTypes to retrieve the TypeObjects associated with a -# * list of TypeIdentifiers. -# * -# * @param in TypeIdentifier sequence -# * @return SampleIdentity -# */ -# RTPS_DllAPI fastrtps::rtps::SampleIdentity get_types( -# const fastrtps::types::TypeIdentifierSeq& in) const; -# -# /** -# * Helps the user to solve all dependencies calling internally to the typelookup service -# * and registers the resulting dynamic type. -# * The registration will be perform asynchronously and the user will be notified through the -# * given callback, which receives the type_name as unique argument. -# * If the type is already registered, the function will return true, but the callback will not be called. -# * If the given type_information is enough to build the type without using the typelookup service, -# * it will return true and the callback will be never called. -# * -# * @param type_information -# * @param type_name -# * @param callback -# * @return true if type is already available (callback will not be called). false if type isn't available yet -# * (the callback will be called if negotiation is success, and ignored in other case). -# */ -# RTPS_DllAPI ReturnCode_t register_remote_type( -# const fastrtps::types::TypeInformation& type_information, -# const std::string& type_name, -# std::function& callback); -# -# /** -# * Register a custom content filter factory, which can be used to create a ContentFilteredTopic. -# * -# * DDS specifies a SQL-like content filter to be used by content filtered topics. -# * If this filter does not meet your filtering requirements, you can register a custom filter factory. -# * -# * To use a custom filter, a factory for it must be registered in the following places: -# * -# * - In any application that uses the custom filter factory to create a ContentFilteredTopic and the corresponding -# * DataReader. -# * -# * - In each application that writes the data to the applications mentioned above. -# * -# * For example, suppose Application A on the subscription side creates a Topic named X and a ContentFilteredTopic -# * named filteredX (and a corresponding DataReader), using a previously registered content filter factory, myFilterFactory. -# * With only that, you will have filtering at the subscription side. -# * If you also want to perform filtering in any application that publishes Topic X, then you also need to register -# * the same definition of the ContentFilterFactory myFilterFactory in that application. -# * -# * Each @c filter_class_name can only be used to register a content filter factory once per DomainParticipant. -# * -# * @param filter_class_name Name of the filter class. Cannot be nullptr, must not exceed 255 characters, and must -# * be unique within this DomainParticipant. -# * @param filter_factory Factory of content filters to be registered. Cannot be nullptr. -# * -# * @return RETCODE_BAD_PARAMETER if any parameter is nullptr, or the filter_class_name exceeds 255 characters. -# * @return RETCODE_PRECONDITION_NOT_MET if the filter_class_name has been already registered. -# * @return RETCODE_PRECONDITION_NOT_MET if filter_class_name is FASTDDS_SQLFILTER_NAME. -# * @return RETCODE_OK if the filter is correctly registered. -# */ -# RTPS_DllAPI ReturnCode_t register_content_filter_factory( -# const char* filter_class_name, -# IContentFilterFactory* const filter_factory); -# -# /** -# * Lookup a custom content filter factory previously registered with register_content_filter_factory. -# * -# * @param filter_class_name Name of the filter class. Cannot be nullptr. -# * -# * @return nullptr if the given filter_class_name has not been previously registered on this DomainParticipant. -# * Otherwise, the content filter factory previously registered with the given filter_class_name. -# */ -# RTPS_DllAPI IContentFilterFactory* lookup_content_filter_factory( -# const char* filter_class_name); -# -# /** -# * Unregister a custom content filter factory previously registered with register_content_filter_factory. -# * -# * A filter_class_name can be unregistered only if it has been previously registered to the DomainParticipant with -# * register_content_filter_factory. -# * -# * The unregistration of filter is not allowed if there are any existing ContentFilteredTopic objects that are -# * using the filter. -# * -# * If there is any existing discovered DataReader with the same filter_class_name, filtering on the writer side will be -# * stopped, but this operation will not fail. -# * -# * @param filter_class_name Name of the filter class. Cannot be nullptr. -# * -# * @return RETCODE_BAD_PARAMETER if the filter_class_name is nullptr. -# * @return RERCODE_PRECONDITION_NOT_MET if the filter_class_name has not been previously registered. -# * @return RERCODE_PRECONDITION_NOT_MET if there is any ContentFilteredTopic referencing the filter. -# * @return RETCODE_OK if the filter is correctly unregistered. -# */ -# RTPS_DllAPI ReturnCode_t unregister_content_filter_factory( -# const char* filter_class_name); -# -# /** -# * @brief Check if the Participant has any Publisher, Subscriber or Topic -# * -# * @return true if any, false otherwise. -# */ -# bool has_active_entities(); diff --git a/fastdds_python/test/api/test_publisher.py b/fastdds_python/test/api/test_publisher.py index 02df14a8..fb2081a7 100644 --- a/fastdds_python/test/api/test_publisher.py +++ b/fastdds_python/test/api/test_publisher.py @@ -295,6 +295,7 @@ def test_get_set_listener(publisher): publisher.set_listener(listener)) assert(publisher.get_listener() == listener) assert(fastdds.StatusMask.all() == publisher.get_status_mask()) + publisher.set_listener(None) def test(status_mask_1, status_mask_2): """ @@ -306,12 +307,14 @@ def test(status_mask_1, status_mask_2): publisher.set_listener(listener, status_mask_1)) assert(publisher.get_listener() == listener) assert(status_mask_1 == publisher.get_status_mask()) + publisher.set_listener(None) listener = PublisherListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == publisher.set_listener(listener, status_mask_2)) assert(publisher.get_listener() == listener) assert(status_mask_2 == publisher.get_status_mask()) + publisher.set_listener(None) # Overload 2: Different status masks test(fastdds.StatusMask.all(), fastdds.StatusMask_all()) diff --git a/fastdds_python/test/api/test_subscriber.py b/fastdds_python/test/api/test_subscriber.py index 79745303..ab9fb5b0 100644 --- a/fastdds_python/test/api/test_subscriber.py +++ b/fastdds_python/test/api/test_subscriber.py @@ -290,6 +290,7 @@ def test_get_set_listener(subscriber): subscriber.set_listener(listener)) assert(subscriber.get_listener() == listener) assert(fastdds.StatusMask.all() == subscriber.get_status_mask()) + subscriber.set_listener(None) def test(status_mask_1, status_mask_2): """ @@ -301,12 +302,14 @@ def test(status_mask_1, status_mask_2): subscriber.set_listener(listener, status_mask_1)) assert(subscriber.get_listener() == listener) assert(status_mask_1 == subscriber.get_status_mask()) + subscriber.set_listener(None) listener = SubscriberListener() assert(listener is not None) assert(fastdds.ReturnCode_t.RETCODE_OK == subscriber.set_listener(listener, status_mask_2)) assert(subscriber.get_listener() == listener) assert(status_mask_2 == subscriber.get_status_mask()) + subscriber.set_listener(None) # Overload 2: Different status masks test(fastdds.StatusMask.all(), fastdds.StatusMask_all()) From 36e6e643f7a426b2fee79c035c6b3d9cbb90f495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Thu, 17 Mar 2022 08:07:45 +0100 Subject: [PATCH 7/8] Refs #13384. Add fixtures to waitset api test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- fastdds_python/test/api/test_waitset.py | 108 +++++++++++++++++------- 1 file changed, 76 insertions(+), 32 deletions(-) diff --git a/fastdds_python/test/api/test_waitset.py b/fastdds_python/test/api/test_waitset.py index 57863334..3695a110 100644 --- a/fastdds_python/test/api/test_waitset.py +++ b/fastdds_python/test/api/test_waitset.py @@ -1,32 +1,89 @@ import fastdds +import pytest import test_complete -def test_waitset(): +@pytest.fixture +def participant(): factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( + return factory.create_participant( 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - subscriber = participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) - assert(subscriber is not None) - test_type = fastdds.TypeSupport(test_complete.CompleteTestTypePubSubType()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.register_type(test_type, test_type.get_type_name())) - topic = participant.create_topic( - "Complete", "CompleteTestType", fastdds.TOPIC_QOS_DEFAULT) - assert(topic is not None) - datawriter_qos = fastdds.DataWriterQos() - datawriter_qos.reliability().kind = fastdds.BEST_EFFORT_RELIABILITY_QOS - datawriter = publisher.create_datawriter(topic, datawriter_qos) - assert(datawriter is not None) + + +@pytest.fixture +def subscriber(participant): + return participant.create_subscriber(fastdds.SUBSCRIBER_QOS_DEFAULT) + + +@pytest.fixture +def topic(participant): + test_type = fastdds.TypeSupport( + test_complete.CompleteTestTypePubSubType()) + participant.register_type(test_type, test_type.get_type_name()) + return participant.create_topic( + "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) + + +@pytest.fixture +def datareader(participant, topic, subscriber): datareader_qos = fastdds.DataReaderQos() datareader_qos.reliability().kind = fastdds.RELIABLE_RELIABILITY_QOS datareader = subscriber.create_datareader(topic, datareader_qos) - assert(datareader is not None) + yield datareader + + assert(fastdds.ReturnCode_t.RETCODE_OK == + subscriber.delete_datareader(datareader)) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_topic(topic)) + assert(fastdds.ReturnCode_t.RETCODE_OK == + participant.delete_subscriber(subscriber)) + factory = fastdds.DomainParticipantFactory.get_instance() + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(participant)) + + +@pytest.fixture +def writer_participant(): + factory = fastdds.DomainParticipantFactory.get_instance() + return factory.create_participant( + 0, fastdds.PARTICIPANT_QOS_DEFAULT) + + +@pytest.fixture +def writer_topic(writer_participant): + test_type = fastdds.TypeSupport( + test_complete.CompleteTestTypePubSubType()) + writer_participant.register_type(test_type, test_type.get_type_name()) + return writer_participant.create_topic( + "Complete", test_type.get_type_name(), fastdds.TOPIC_QOS_DEFAULT) + + +@pytest.fixture +def publisher(writer_participant): + return writer_participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) + + +@pytest.fixture +def datawriter(writer_participant, writer_topic, publisher): + datawriter_qos = fastdds.DataWriterQos() + datawriter_qos.reliability().kind = fastdds.BEST_EFFORT_RELIABILITY_QOS + datawriter = publisher.create_datawriter(writer_topic, datawriter_qos) + + yield datawriter + + assert(fastdds.ReturnCode_t.RETCODE_OK == + publisher.delete_datawriter(datawriter)) + assert(fastdds.ReturnCode_t.RETCODE_OK == + writer_participant.delete_topic(writer_topic)) + assert(fastdds.ReturnCode_t.RETCODE_OK == + writer_participant.delete_publisher(publisher)) + factory = fastdds.DomainParticipantFactory.get_instance() + assert(fastdds.ReturnCode_t.RETCODE_OK == + factory.delete_participant(writer_participant)) + + +def test_waitset(datareader, datawriter): status_cond = datareader.get_statuscondition() guard_cond = fastdds.GuardCondition() waitset = fastdds.WaitSet() @@ -75,16 +132,3 @@ def test_waitset(): waitset.detach_condition(status_cond)) assert(fastdds.ReturnCode_t.RETCODE_OK == waitset.detach_condition(guard_cond)) - - assert(fastdds.ReturnCode_t.RETCODE_OK == - subscriber.delete_datareader(datareader)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - publisher.delete_datawriter(datawriter)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_topic(topic)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_subscriber(subscriber)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) From 292ca9c81625651051beba635b5e29e5fae070ef Mon Sep 17 00:00:00 2001 From: Javier Santiago Date: Wed, 13 Apr 2022 12:36:56 +0200 Subject: [PATCH 8/8] Refs #13384: Applied suggestions Signed-off-by: Javier Santiago --- fastdds_python/test/api/test_publisher.py | 15 +-------------- fastdds_python/test/api/test_subscriber.py | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/fastdds_python/test/api/test_publisher.py b/fastdds_python/test/api/test_publisher.py index fb2081a7..6546eb08 100644 --- a/fastdds_python/test/api/test_publisher.py +++ b/fastdds_python/test/api/test_publisher.py @@ -394,30 +394,17 @@ def test_lookup_datawriter(topic, publisher): publisher.delete_datawriter(datawriter)) -def test_suspend_publications(): +def test_suspend_publications(publisher): """ This test checks: - Publisher::suspend_publications - Publisher::resume_publications """ - factory = fastdds.DomainParticipantFactory.get_instance() - assert(factory is not None) - participant = factory.create_participant( - 0, fastdds.PARTICIPANT_QOS_DEFAULT) - assert(participant is not None) - publisher = participant.create_publisher(fastdds.PUBLISHER_QOS_DEFAULT) - assert(publisher is not None) - assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == publisher.suspend_publications()) assert(fastdds.ReturnCode_t.RETCODE_UNSUPPORTED == publisher.resume_publications()) - assert(fastdds.ReturnCode_t.RETCODE_OK == - participant.delete_publisher(publisher)) - assert(fastdds.ReturnCode_t.RETCODE_OK == - factory.delete_participant(participant)) - def test_wait_for_acknowlegments(publisher): """ diff --git a/fastdds_python/test/api/test_subscriber.py b/fastdds_python/test/api/test_subscriber.py index ab9fb5b0..200156af 100644 --- a/fastdds_python/test/api/test_subscriber.py +++ b/fastdds_python/test/api/test_subscriber.py @@ -177,7 +177,7 @@ def test(status_mask_1, status_mask_2, listnr=None): listener) -def test_deleted_contained_entities(participant, topic, subscriber): +def test_delete_contained_entities(participant, topic, subscriber): """ This test checks: - Subscriber::delete_contained_entities