diff --git a/fastdds_python/test/CMakeLists.txt b/fastdds_python/test/CMakeLists.txt index c856b84b..8a19e345 100644 --- a/fastdds_python/test/CMakeLists.txt +++ b/fastdds_python/test/CMakeLists.txt @@ -20,7 +20,6 @@ add_test(NAME api_tests ${Python3_EXECUTABLE} -m pytest -vrP - --cdr v2 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/api ) diff --git a/fastdds_python/test/api/conftest.py b/fastdds_python/test/api/conftest.py deleted file mode 100644 index 1d776c09..00000000 --- a/fastdds_python/test/api/conftest.py +++ /dev/null @@ -1,3 +0,0 @@ - -def pytest_addoption(parser): - parser.addoption("--cdr", action="store", default="v2") diff --git a/fastdds_python/test/api/test_datareader.py b/fastdds_python/test/api/test_datareader.py index c63fb204..211ac0e0 100644 --- a/fastdds_python/test/api/test_datareader.py +++ b/fastdds_python/test/api/test_datareader.py @@ -6,10 +6,6 @@ class DataReaderListener (fastdds.DataReaderListener): def __init__(self): super().__init__() -@pytest.fixture -def cdr_version(request): - return request.config.getoption('--cdr') - @pytest.fixture(params=['no_module', 'module'], autouse=True) def data_type(request): if request.param == 'no_module': @@ -112,8 +108,7 @@ def datawriter(writer_participant, writer_topic, publisher): factory.delete_participant(writer_participant)) -# This function should be used in a test which uses 'cdr_version' fixture -def fill_keyed_complete_test_type(data, cdr_version): +def fill_keyed_complete_test_type(data): # Auxiliary StructTypes struct_type1 = pytest.dds_type.StructType() struct_type1.char_field('\x01') @@ -186,34 +181,19 @@ def fill_keyed_complete_test_type(data, cdr_version): data.struct_field().string_field("Test string") data.struct_field().enum_field(pytest.dds_type.Color_MAGENTA) data.struct_field().enum2_field(pytest.dds_type.Material_METAL) - if (cdr_version == 'v1'): - data.char_opt_field('\x01') - data.uint8_opt_field(254) - data.int16_opt_field(-10) - data.uint16_opt_field(10) - data.int32_opt_field(-1000) - data.uint32_opt_field(1000) - data.int64_opt_field(-36000) - data.uint64_opt_field(36000) - data.float_opt_field(1.0) - data.double_opt_field(1202.5) - data.bool_opt_field(True) - data.string_opt_field("Test string") - data.enum_opt_field(pytest.dds_type.Color_MAGENTA) - else: - data.char_opt_field().set_value('\x01') - data.uint8_opt_field().set_value(254) - data.int16_opt_field().set_value(-10) - data.uint16_opt_field().set_value(10) - data.int32_opt_field().set_value(-1000) - data.uint32_opt_field().set_value(1000) - data.int64_opt_field().set_value(-36000) - data.uint64_opt_field().set_value(36000) - data.float_opt_field().set_value(1.0) - data.double_opt_field().set_value(1202.5) - data.bool_opt_field().set_value(True) - data.string_opt_field().set_value("Test string") - data.enum_opt_field().set_value(pytest.dds_type.Color_MAGENTA) + data.char_opt_field().set_value('\x01') + data.uint8_opt_field().set_value(254) + data.int16_opt_field().set_value(-10) + data.uint16_opt_field().set_value(10) + data.int32_opt_field().set_value(-1000) + data.uint32_opt_field().set_value(1000) + data.int64_opt_field().set_value(-36000) + data.uint64_opt_field().set_value(36000) + data.float_opt_field().set_value(1.0) + data.double_opt_field().set_value(1202.5) + data.bool_opt_field().set_value(True) + data.string_opt_field().set_value("Test string") + data.enum_opt_field().set_value(pytest.dds_type.Color_MAGENTA) struct_field = pytest.dds_type.StructType() struct_field.char_field('\x01') struct_field.uint8_field(254) @@ -229,10 +209,7 @@ def fill_keyed_complete_test_type(data, cdr_version): struct_field.string_field("Test string") struct_field.enum_field(pytest.dds_type.Color_MAGENTA) struct_field.enum2_field(pytest.dds_type.Material_METAL) - if (cdr_version == 'v1'): - data.struct_opt_field(struct_field) - else: - data.struct_opt_field().set_value(struct_field) + data.struct_opt_field().set_value(struct_field) data.array_char_field(['\x01', '\x02', '\x03']) data.array_uint8_field([254, 255, 1]) data.array_int16_field([-10, 10, -20]) @@ -283,8 +260,7 @@ def fill_keyed_complete_test_type(data, cdr_version): data.unbounded_sequence_struct_field([struct_type1, struct_type2, struct_type3]) -# This function should be used in a test which uses 'cdr_version' fixture -def check_keyed_complete_test_type(data, cdr_version): +def check_keyed_complete_test_type(data): assert(data.char_field() == '\x01') assert(data.uint8_field() == 254) assert(data.int16_field() == -10) @@ -313,49 +289,34 @@ def check_keyed_complete_test_type(data, cdr_version): assert(data.struct_field().string_field() == "Test string") assert(data.struct_field().enum_field() == pytest.dds_type.Color_MAGENTA) assert(data.struct_field().enum2_field() == pytest.dds_type.Material_METAL) - if cdr_version == 'v1': - assert(data.char_opt_field() == '\x01') - assert(data.uint8_opt_field() == 254) - assert(data.int16_opt_field() == -10) - assert(data.uint16_opt_field() == 10) - assert(data.int32_opt_field() == -1000) - assert(data.uint32_opt_field() == 1000) - assert(data.int64_opt_field() == -36000) - assert(data.uint64_opt_field() == 36000) - assert(data.float_opt_field() == 1.0) - assert(data.double_opt_field() == 1202.5) - assert(data.bool_opt_field() == True) - assert(data.string_opt_field() == "Test string") - assert(data.enum_opt_field() == pytest.dds_type.Color_MAGENTA) - else: - assert(data.char_opt_field().has_value()) - assert(data.char_opt_field().get_value() == '\x01') - assert(data.uint8_opt_field().has_value()) - assert(data.uint8_opt_field().get_value() == 254) - assert(data.int16_opt_field().has_value()) - assert(data.int16_opt_field().get_value() == -10) - assert(data.uint16_opt_field().has_value()) - assert(data.uint16_opt_field().get_value() == 10) - assert(data.int32_opt_field().has_value()) - assert(data.int32_opt_field().get_value() == -1000) - assert(data.uint32_opt_field().has_value()) - assert(data.uint32_opt_field().get_value() == 1000) - assert(data.int64_opt_field().has_value()) - assert(data.int64_opt_field().get_value() == -36000) - assert(data.uint64_opt_field().has_value()) - assert(data.uint64_opt_field().get_value() == 36000) - assert(data.float_opt_field().has_value()) - assert(data.float_opt_field().get_value() == 1.0) - assert(data.double_opt_field().has_value()) - assert(data.double_opt_field().get_value() == 1202.5) - assert(data.bool_opt_field().has_value()) - assert(data.bool_opt_field().get_value() == True) - assert(data.string_opt_field().has_value()) - assert(data.string_opt_field().get_value() == "Test string") - assert(data.enum_opt_field().has_value()) - assert(data.enum_opt_field().get_value() == pytest.dds_type.Color_MAGENTA) - assert(not data.enum2_opt_field().has_value()) - assert(data.struct_opt_field().has_value()) + assert(data.char_opt_field().has_value()) + assert(data.char_opt_field().get_value() == '\x01') + assert(data.uint8_opt_field().has_value()) + assert(data.uint8_opt_field().get_value() == 254) + assert(data.int16_opt_field().has_value()) + assert(data.int16_opt_field().get_value() == -10) + assert(data.uint16_opt_field().has_value()) + assert(data.uint16_opt_field().get_value() == 10) + assert(data.int32_opt_field().has_value()) + assert(data.int32_opt_field().get_value() == -1000) + assert(data.uint32_opt_field().has_value()) + assert(data.uint32_opt_field().get_value() == 1000) + assert(data.int64_opt_field().has_value()) + assert(data.int64_opt_field().get_value() == -36000) + assert(data.uint64_opt_field().has_value()) + assert(data.uint64_opt_field().get_value() == 36000) + assert(data.float_opt_field().has_value()) + assert(data.float_opt_field().get_value() == 1.0) + assert(data.double_opt_field().has_value()) + assert(data.double_opt_field().get_value() == 1202.5) + assert(data.bool_opt_field().has_value()) + assert(data.bool_opt_field().get_value() == True) + assert(data.string_opt_field().has_value()) + assert(data.string_opt_field().get_value() == "Test string") + assert(data.enum_opt_field().has_value()) + assert(data.enum_opt_field().get_value() == pytest.dds_type.Color_MAGENTA) + assert(not data.enum2_opt_field().has_value()) + assert(data.struct_opt_field().has_value()) assert(data.struct_opt_field().char_field() == '\x01') assert(data.struct_opt_field().uint8_field() == 254) assert(data.struct_opt_field().int16_field() == -10) @@ -989,8 +950,7 @@ def test_lookup_instance(transient_datareader_qos, test_keyed_type, datareader, assert(writer_ih == ih) -def test_read(transient_datareader_qos, datareader, - datawriter, cdr_version): +def test_read(transient_datareader_qos, datareader, datawriter): """ This test checks: - DataReader::read @@ -1007,7 +967,7 @@ def test_read(transient_datareader_qos, datareader, assert(0 == len(info_seq)) sample = pytest.dds_type.CompleteTestType() - fill_keyed_complete_test_type(sample, cdr_version) + fill_keyed_complete_test_type(sample) assert(fastdds.RETCODE_OK == datawriter.write(sample)) assert(datareader.wait_for_unread_message( @@ -1022,13 +982,13 @@ def test_read(transient_datareader_qos, datareader, assert(0 < info_seq[0].source_timestamp.to_ns()) assert(0 < info_seq[0].reception_timestamp.to_ns()) assert(sample == data_seq[0]) - check_keyed_complete_test_type(data_seq[0], cdr_version) + check_keyed_complete_test_type(data_seq[0]) assert(fastdds.RETCODE_OK == datareader.return_loan(data_seq, info_seq)) def test_read_instance(transient_datareader_qos, test_keyed_type, - datareader, datawriter, cdr_version): + datareader, datawriter): """ This test checks: - DataReader::read_instance @@ -1046,7 +1006,7 @@ def test_read_instance(transient_datareader_qos, test_keyed_type, assert(0 == len(info_seq)) sample = pytest.dds_type.KeyedCompleteTestType() - fill_keyed_complete_test_type(sample, cdr_version) + fill_keyed_complete_test_type(sample) ih = datawriter.register_instance(sample) assert(fastdds.RETCODE_OK == datawriter.write(sample, ih)) @@ -1063,13 +1023,13 @@ def test_read_instance(transient_datareader_qos, test_keyed_type, assert(0 < info_seq[0].source_timestamp.to_ns()) assert(0 < info_seq[0].reception_timestamp.to_ns()) assert(sample == data_seq[0]) - check_keyed_complete_test_type(data_seq[0], cdr_version) + check_keyed_complete_test_type(data_seq[0]) assert(fastdds.RETCODE_OK == datareader.return_loan(data_seq, info_seq)) def test_read_next_instance(transient_datareader_qos, test_keyed_type, - datareader, datawriter, cdr_version): + datareader, datawriter): """ This test checks: - DataReader::read_next_instance @@ -1087,7 +1047,7 @@ def test_read_next_instance(transient_datareader_qos, test_keyed_type, assert(0 == len(info_seq)) sample = pytest.dds_type.KeyedCompleteTestType() - fill_keyed_complete_test_type(sample, cdr_version) + fill_keyed_complete_test_type(sample) assert(fastdds.RETCODE_OK == datawriter.write(sample)) assert(datareader.wait_for_unread_message( @@ -1103,13 +1063,13 @@ def test_read_next_instance(transient_datareader_qos, test_keyed_type, assert(0 < info_seq[0].source_timestamp.to_ns()) assert(0 < info_seq[0].reception_timestamp.to_ns()) assert(sample == data_seq[0]) - check_keyed_complete_test_type(data_seq[0], cdr_version) + check_keyed_complete_test_type(data_seq[0]) assert(fastdds.RETCODE_OK == datareader.return_loan(data_seq, info_seq)) def test_read_next_sample(transient_datareader_qos, datareader, - datawriter, cdr_version): + datawriter): """ This test checks: - DataReader::read_next_sample @@ -1121,7 +1081,7 @@ def test_read_next_sample(transient_datareader_qos, datareader, data, info)) sample = pytest.dds_type.CompleteTestType() - fill_keyed_complete_test_type(sample, cdr_version) + fill_keyed_complete_test_type(sample) assert(fastdds.RETCODE_OK == datawriter.write(sample)) assert(datareader.wait_for_unread_message( @@ -1132,11 +1092,11 @@ def test_read_next_sample(transient_datareader_qos, datareader, assert(0 < info.source_timestamp.to_ns()) assert(0 < info.reception_timestamp.to_ns()) assert(sample == data) - check_keyed_complete_test_type(data, cdr_version) + check_keyed_complete_test_type(data) def test_take(transient_datareader_qos, datareader, - datawriter, cdr_version): + datawriter): """ This test checks: - DataReader::take @@ -1153,7 +1113,7 @@ def test_take(transient_datareader_qos, datareader, assert(0 == len(info_seq)) sample = pytest.dds_type.CompleteTestType() - fill_keyed_complete_test_type(sample, cdr_version) + fill_keyed_complete_test_type(sample) assert(fastdds.RETCODE_OK == datawriter.write(sample)) assert(datareader.wait_for_unread_message( @@ -1168,13 +1128,13 @@ def test_take(transient_datareader_qos, datareader, assert(0 < info_seq[0].source_timestamp.to_ns()) assert(0 < info_seq[0].reception_timestamp.to_ns()) assert(sample == data_seq[0]) - check_keyed_complete_test_type(data_seq[0], cdr_version) + check_keyed_complete_test_type(data_seq[0]) assert(fastdds.RETCODE_OK == datareader.return_loan(data_seq, info_seq)) def test_take_instance(transient_datareader_qos, test_keyed_type, - datareader, datawriter, cdr_version): + datareader, datawriter): """ This test checks: - DataReader::take_instance @@ -1192,7 +1152,7 @@ def test_take_instance(transient_datareader_qos, test_keyed_type, assert(0 == len(info_seq)) sample = pytest.dds_type.KeyedCompleteTestType() - fill_keyed_complete_test_type(sample, cdr_version) + fill_keyed_complete_test_type(sample) ih = datawriter.register_instance(sample) assert(fastdds.RETCODE_OK == datawriter.write(sample, ih)) @@ -1209,13 +1169,13 @@ def test_take_instance(transient_datareader_qos, test_keyed_type, assert(0 < info_seq[0].source_timestamp.to_ns()) assert(0 < info_seq[0].reception_timestamp.to_ns()) assert(sample == data_seq[0]) - check_keyed_complete_test_type(data_seq[0], cdr_version) + check_keyed_complete_test_type(data_seq[0]) assert(fastdds.RETCODE_OK == datareader.return_loan(data_seq, info_seq)) def test_take_next_instance(transient_datareader_qos, test_keyed_type, - datareader, datawriter, cdr_version): + datareader, datawriter): """ This test checks: - DataReader::take_next_instance @@ -1233,7 +1193,7 @@ def test_take_next_instance(transient_datareader_qos, test_keyed_type, assert(0 == len(info_seq)) sample = pytest.dds_type.KeyedCompleteTestType() - fill_keyed_complete_test_type(sample, cdr_version) + fill_keyed_complete_test_type(sample) assert(fastdds.RETCODE_OK == datawriter.write(sample)) assert(datareader.wait_for_unread_message( @@ -1249,13 +1209,13 @@ def test_take_next_instance(transient_datareader_qos, test_keyed_type, assert(0 < info_seq[0].source_timestamp.to_ns()) assert(0 < info_seq[0].reception_timestamp.to_ns()) assert(sample == data_seq[0]) - check_keyed_complete_test_type(data_seq[0], cdr_version) + check_keyed_complete_test_type(data_seq[0]) assert(fastdds.RETCODE_OK == datareader.return_loan(data_seq, info_seq)) def test_take_next_sample(transient_datareader_qos, datareader, - datawriter, cdr_version): + datawriter): """ This test checks: - DataReader::take_next_sample @@ -1267,7 +1227,7 @@ def test_take_next_sample(transient_datareader_qos, datareader, data, info)) sample = pytest.dds_type.CompleteTestType() - fill_keyed_complete_test_type(sample, cdr_version) + fill_keyed_complete_test_type(sample) assert(fastdds.RETCODE_OK == datawriter.write(sample)) assert(datareader.wait_for_unread_message( @@ -1278,7 +1238,7 @@ def test_take_next_sample(transient_datareader_qos, datareader, assert(0 < info.source_timestamp.to_ns()) assert(0 < info.reception_timestamp.to_ns()) assert(sample == data) - check_keyed_complete_test_type(data, cdr_version) + check_keyed_complete_test_type(data) def test_get_type(test_type, datareader):