Skip to content

Commit e89a029

Browse files
Add tests for new QoS getters from raw XML (#189)
* Refs #21745. Remove zombie file Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #21745. Add tests for new API Signed-off-by: Juan Lopez Fernandez <[email protected]> * Refs #21745. Apply suggestions Signed-off-by: Juan Lopez Fernandez <[email protected]> --------- Signed-off-by: Juan Lopez Fernandez <[email protected]>
1 parent 9a18286 commit e89a029

File tree

6 files changed

+529
-47
lines changed

6 files changed

+529
-47
lines changed

fastdds_python/test/api/DEFAULT_FASTRTPS_PROFILES.xml

Lines changed: 0 additions & 47 deletions
This file was deleted.

fastdds_python/test/api/test_domainparticipant.py

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,3 +796,248 @@ def second_participant():
796796
factory.delete_participant(participant))
797797
assert(fastdds.RETCODE_OK ==
798798
factory.delete_participant(participant2))
799+
800+
def test_get_publisher_qos_from_xml():
801+
802+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
803+
xml_content = file.read()
804+
805+
factory = fastdds.DomainParticipantFactory.get_instance()
806+
participant = factory.create_participant(
807+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
808+
809+
qos = fastdds.PublisherQos()
810+
ret = participant.get_publisher_qos_from_xml(
811+
xml_content, qos, 'test_publisher_profile')
812+
assert(fastdds.RETCODE_OK == ret)
813+
814+
qos_no_name = fastdds.PublisherQos()
815+
ret = participant.get_publisher_qos_from_xml(
816+
xml_content, qos_no_name)
817+
assert(fastdds.RETCODE_OK == ret)
818+
819+
# Non matching name takes the first publisher found (the only one)
820+
assert(qos == qos_no_name)
821+
822+
assert(fastdds.RETCODE_OK ==
823+
factory.delete_participant(participant))
824+
825+
def test_get_default_publisher_qos_from_xml():
826+
827+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
828+
xml_content = file.read()
829+
830+
factory = fastdds.DomainParticipantFactory.get_instance()
831+
participant = factory.create_participant(
832+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
833+
834+
default_qos = fastdds.PublisherQos()
835+
ret = participant.get_default_publisher_qos_from_xml(
836+
xml_content, default_qos)
837+
assert(fastdds.RETCODE_OK == ret)
838+
839+
qos = fastdds.PublisherQos()
840+
ret = participant.get_publisher_qos_from_xml(
841+
xml_content, qos, 'test_publisher_profile')
842+
assert(fastdds.RETCODE_OK == ret)
843+
844+
assert(default_qos == qos)
845+
846+
assert(fastdds.RETCODE_OK ==
847+
factory.delete_participant(participant))
848+
849+
def test_get_subscriber_qos_from_xml():
850+
851+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
852+
xml_content = file.read()
853+
854+
factory = fastdds.DomainParticipantFactory.get_instance()
855+
participant = factory.create_participant(
856+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
857+
858+
qos = fastdds.SubscriberQos()
859+
ret = participant.get_subscriber_qos_from_xml(
860+
xml_content, qos, 'test_subscriber_profile')
861+
assert(fastdds.RETCODE_OK == ret)
862+
863+
qos_no_name = fastdds.SubscriberQos()
864+
ret = participant.get_subscriber_qos_from_xml(
865+
xml_content, qos_no_name)
866+
assert(fastdds.RETCODE_OK == ret)
867+
868+
# Non matching name takes the first subscriber found (the only one)
869+
assert(qos == qos_no_name)
870+
871+
assert(fastdds.RETCODE_OK ==
872+
factory.delete_participant(participant))
873+
874+
def test_get_default_subscriber_qos_from_xml():
875+
876+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
877+
xml_content = file.read()
878+
879+
factory = fastdds.DomainParticipantFactory.get_instance()
880+
participant = factory.create_participant(
881+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
882+
883+
default_qos = fastdds.SubscriberQos()
884+
ret = participant.get_default_subscriber_qos_from_xml(
885+
xml_content, default_qos)
886+
assert(fastdds.RETCODE_OK == ret)
887+
888+
qos = fastdds.SubscriberQos()
889+
ret = participant.get_subscriber_qos_from_xml(
890+
xml_content, qos, 'test_subscriber_profile')
891+
assert(fastdds.RETCODE_OK == ret)
892+
893+
assert(default_qos == qos)
894+
895+
assert(fastdds.RETCODE_OK ==
896+
factory.delete_participant(participant))
897+
898+
def test_get_topic_qos_from_xml():
899+
900+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
901+
xml_content = file.read()
902+
903+
factory = fastdds.DomainParticipantFactory.get_instance()
904+
participant = factory.create_participant(
905+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
906+
907+
qos = fastdds.TopicQos()
908+
ret = participant.get_topic_qos_from_xml(
909+
xml_content, qos, 'test_topic_profile')
910+
assert(fastdds.RETCODE_OK == ret)
911+
912+
qos_no_name = fastdds.TopicQos()
913+
ret = participant.get_topic_qos_from_xml(
914+
xml_content, qos_no_name)
915+
assert(fastdds.RETCODE_OK == ret)
916+
917+
# Non matching name takes the first topic found (the only one)
918+
assert(qos == qos_no_name)
919+
920+
assert(fastdds.RETCODE_OK ==
921+
factory.delete_participant(participant))
922+
923+
def test_get_default_topic_qos_from_xml():
924+
925+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
926+
xml_content = file.read()
927+
928+
factory = fastdds.DomainParticipantFactory.get_instance()
929+
participant = factory.create_participant(
930+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
931+
932+
default_qos = fastdds.TopicQos()
933+
ret = participant.get_default_topic_qos_from_xml(
934+
xml_content, default_qos)
935+
assert(fastdds.RETCODE_OK == ret)
936+
937+
qos = fastdds.TopicQos()
938+
ret = participant.get_topic_qos_from_xml(
939+
xml_content, qos, 'test_topic_profile')
940+
assert(fastdds.RETCODE_OK == ret)
941+
942+
assert(default_qos == qos)
943+
944+
assert(fastdds.RETCODE_OK ==
945+
factory.delete_participant(participant))
946+
947+
def test_get_requester_qos_from_xml():
948+
949+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
950+
xml_content = file.read()
951+
952+
factory = fastdds.DomainParticipantFactory.get_instance()
953+
participant = factory.create_participant(
954+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
955+
956+
qos = fastdds.RequesterQos()
957+
ret = participant.get_requester_qos_from_xml(
958+
xml_content, qos, 'test_requester_profile')
959+
assert(fastdds.RETCODE_OK == ret)
960+
961+
qos_no_name = fastdds.RequesterQos()
962+
ret = participant.get_requester_qos_from_xml(
963+
xml_content, qos_no_name)
964+
assert(fastdds.RETCODE_OK == ret)
965+
966+
# Non matching name takes the first requester found (the only one)
967+
assert(qos == qos_no_name)
968+
969+
assert(fastdds.RETCODE_OK ==
970+
factory.delete_participant(participant))
971+
972+
def test_get_default_requester_qos_from_xml():
973+
974+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
975+
xml_content = file.read()
976+
977+
factory = fastdds.DomainParticipantFactory.get_instance()
978+
participant = factory.create_participant(
979+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
980+
981+
default_qos = fastdds.RequesterQos()
982+
ret = participant.get_default_requester_qos_from_xml(
983+
xml_content, default_qos)
984+
assert(fastdds.RETCODE_OK == ret)
985+
986+
qos = fastdds.RequesterQos()
987+
ret = participant.get_requester_qos_from_xml(
988+
xml_content, qos, 'test_requester_profile')
989+
assert(fastdds.RETCODE_OK == ret)
990+
991+
assert(default_qos == qos)
992+
993+
assert(fastdds.RETCODE_OK ==
994+
factory.delete_participant(participant))
995+
996+
def test_get_replier_qos_from_xml():
997+
998+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
999+
xml_content = file.read()
1000+
1001+
factory = fastdds.DomainParticipantFactory.get_instance()
1002+
participant = factory.create_participant(
1003+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
1004+
1005+
qos = fastdds.ReplierQos()
1006+
ret = participant.get_replier_qos_from_xml(
1007+
xml_content, qos, 'test_replier_profile')
1008+
assert(fastdds.RETCODE_OK == ret)
1009+
1010+
qos_no_name = fastdds.ReplierQos()
1011+
ret = participant.get_replier_qos_from_xml(
1012+
xml_content, qos_no_name)
1013+
assert(fastdds.RETCODE_OK == ret)
1014+
1015+
# Non matching name takes the first replier found (the only one)
1016+
assert(qos == qos_no_name)
1017+
1018+
assert(fastdds.RETCODE_OK ==
1019+
factory.delete_participant(participant))
1020+
1021+
def test_get_default_replier_qos_from_xml():
1022+
1023+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
1024+
xml_content = file.read()
1025+
1026+
factory = fastdds.DomainParticipantFactory.get_instance()
1027+
participant = factory.create_participant(
1028+
0, fastdds.PARTICIPANT_QOS_DEFAULT)
1029+
1030+
default_qos = fastdds.ReplierQos()
1031+
ret = participant.get_default_replier_qos_from_xml(
1032+
xml_content, default_qos)
1033+
assert(fastdds.RETCODE_OK == ret)
1034+
1035+
qos = fastdds.ReplierQos()
1036+
ret = participant.get_replier_qos_from_xml(
1037+
xml_content, qos, 'test_replier_profile')
1038+
assert(fastdds.RETCODE_OK == ret)
1039+
1040+
assert(default_qos == qos)
1041+
1042+
assert(fastdds.RETCODE_OK ==
1043+
factory.delete_participant(participant))

fastdds_python/test/api/test_domainparticipantfactory.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,81 @@ def test(status_mask, listnr=None):
208208
fastdds.StatusMask.sample_rejected() <<
209209
fastdds.StatusMask.subscription_matched(),
210210
listener)
211+
212+
def test_get_participant_qos_from_xml():
213+
214+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
215+
xml_content = file.read()
216+
217+
factory = fastdds.DomainParticipantFactory.get_instance()
218+
219+
qos = fastdds.DomainParticipantQos()
220+
ret = factory.get_participant_qos_from_xml(
221+
xml_content, qos, 'test_participant_profile')
222+
assert(fastdds.RETCODE_OK == ret)
223+
224+
qos_no_name = fastdds.DomainParticipantQos()
225+
ret = factory.get_participant_qos_from_xml(
226+
xml_content, qos_no_name)
227+
assert(fastdds.RETCODE_OK == ret)
228+
229+
# Non matching name takes the first participant found (the only one)
230+
assert(qos == qos_no_name)
231+
232+
def test_get_default_participant_qos_from_xml():
233+
234+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
235+
xml_content = file.read()
236+
237+
factory = fastdds.DomainParticipantFactory.get_instance()
238+
239+
default_qos = fastdds.DomainParticipantQos()
240+
ret = factory.get_default_participant_qos_from_xml(
241+
xml_content, default_qos)
242+
assert(fastdds.RETCODE_OK == ret)
243+
244+
qos = fastdds.DomainParticipantQos()
245+
ret = factory.get_participant_qos_from_xml(
246+
xml_content, qos, 'test_participant_profile')
247+
assert(fastdds.RETCODE_OK == ret)
248+
249+
assert(default_qos == qos)
250+
251+
def test_get_participant_extended_qos_from_xml():
252+
253+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
254+
xml_content = file.read()
255+
256+
factory = fastdds.DomainParticipantFactory.get_instance()
257+
258+
qos = fastdds.DomainParticipantExtendedQos()
259+
ret = factory.get_participant_extended_qos_from_xml(
260+
xml_content, qos, 'test_participant_profile')
261+
assert(fastdds.RETCODE_OK == ret)
262+
263+
qos_no_name = fastdds.DomainParticipantExtendedQos()
264+
ret = factory.get_participant_extended_qos_from_xml(
265+
xml_content, qos_no_name)
266+
assert(fastdds.RETCODE_OK == ret)
267+
268+
# Non matching name takes the first participant found (the only one)
269+
assert(qos == qos_no_name)
270+
271+
def test_get_default_participant_extended_qos_from_xml():
272+
273+
with open("test_xml_profile.xml", "r", encoding="utf-8") as file:
274+
xml_content = file.read()
275+
276+
factory = fastdds.DomainParticipantFactory.get_instance()
277+
278+
default_qos = fastdds.DomainParticipantExtendedQos()
279+
ret = factory.get_default_participant_extended_qos_from_xml(
280+
xml_content, default_qos)
281+
assert(fastdds.RETCODE_OK == ret)
282+
283+
qos = fastdds.DomainParticipantExtendedQos()
284+
ret = factory.get_participant_extended_qos_from_xml(
285+
xml_content, qos, 'test_participant_profile')
286+
assert(fastdds.RETCODE_OK == ret)
287+
288+
assert(default_qos == qos)

0 commit comments

Comments
 (0)