|
1 | 1 | from ansys.dpf import core as dpf |
2 | 2 | from conftest import ( |
3 | | - SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, |
| 3 | + SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0, |
4 | 4 | ) |
5 | 5 | import pytest |
6 | 6 |
|
@@ -68,3 +68,67 @@ def test_get_property_description_generic_data_container(server_type): |
68 | 68 | "my-string": "str", |
69 | 69 | "my-field": "Field", |
70 | 70 | } |
| 71 | + |
| 72 | + |
| 73 | +@pytest.mark.skipif( |
| 74 | + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, reason="Available for servers >=7.0" |
| 75 | +) |
| 76 | +def test_get_by_type_generic_data_container(server_type): |
| 77 | + gdc = dpf.GenericDataContainer(server=server_type) |
| 78 | + entity = 42 |
| 79 | + gdc.set_property("my-int", entity) |
| 80 | + new_entity = gdc.get_property("my-int") |
| 81 | + assert 42 == new_entity |
| 82 | + new_entity = gdc.get_property("my-int", int) |
| 83 | + assert 42 == new_entity |
| 84 | + new_entity = gdc.get_property("my-int", dpf.types.int) |
| 85 | + assert 42 == new_entity |
| 86 | + |
| 87 | + entity = 4.2 |
| 88 | + gdc.set_property("my-float", entity) |
| 89 | + new_entity = gdc.get_property("my-float") |
| 90 | + assert 4.2 == new_entity |
| 91 | + new_entity = gdc.get_property("my-float", float) |
| 92 | + assert 4.2 == new_entity |
| 93 | + new_entity = gdc.get_property("my-float", dpf.types.double) |
| 94 | + assert 4.2 == new_entity |
| 95 | + |
| 96 | + entity = "hello world" |
| 97 | + gdc.set_property("my-string", entity) |
| 98 | + new_entity = gdc.get_property("my-string") |
| 99 | + assert "hello world" == new_entity |
| 100 | + new_entity = gdc.get_property("my-string", str) |
| 101 | + assert "hello world" == new_entity |
| 102 | + new_entity = gdc.get_property("my-string", dpf.types.string) |
| 103 | + assert "hello world" == new_entity |
| 104 | + |
| 105 | + entity = dpf.Field(location="phase", nature=dpf.natures.scalar, server=server_type) |
| 106 | + gdc.set_property("my-field", entity) |
| 107 | + new_entity = gdc.get_property("my-field") |
| 108 | + assert isinstance(new_entity, dpf.Field) |
| 109 | + |
| 110 | + new_entity = gdc.get_property("my-field", dpf.Field) |
| 111 | + assert isinstance(new_entity, dpf.Field) |
| 112 | + |
| 113 | + new_entity = gdc.get_property("my-field", dpf.types.field) |
| 114 | + assert isinstance(new_entity, dpf.Field) |
| 115 | + |
| 116 | + |
| 117 | +@pytest.mark.skipif( |
| 118 | + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0, reason="Available for servers >=8.0" |
| 119 | +) |
| 120 | +def test_get_bytes_generic_data_container(server_type): |
| 121 | + gdc = dpf.GenericDataContainer(server=server_type) |
| 122 | + |
| 123 | + entity = "hello world" |
| 124 | + gdc.set_property("my-string", entity) |
| 125 | + new_entity = gdc.get_property("my-string") |
| 126 | + assert "hello world" == new_entity |
| 127 | + new_entity = gdc.get_property("my-string", str) |
| 128 | + assert "hello world" == new_entity |
| 129 | + new_entity = gdc.get_property("my-string", dpf.types.string) |
| 130 | + assert "hello world" == new_entity |
| 131 | + new_entity = gdc.get_property("my-string", bytes) |
| 132 | + assert b"hello world" == new_entity |
| 133 | + new_entity = gdc.get_property("my-string", dpf.types.bytes) |
| 134 | + assert b"hello world" == new_entity |
0 commit comments