|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
| 14 | +import assertpy |
| 15 | +import pytest |
14 | 16 |
|
15 | 17 | from feast.entity import Entity |
16 | 18 | from feast.value_type import ValueType |
17 | 19 |
|
18 | 20 |
|
19 | 21 | def test_join_key_default(): |
20 | | - entity = Entity("my-entity", description="My entity", value_type=ValueType.STRING) |
| 22 | + with pytest.deprecated_call(): |
| 23 | + entity = Entity( |
| 24 | + "my-entity", description="My entity", value_type=ValueType.STRING |
| 25 | + ) |
21 | 26 | assert entity.join_key == "my-entity" |
22 | 27 |
|
23 | 28 |
|
24 | 29 | def test_entity_class_contains_tags(): |
25 | | - entity = Entity( |
26 | | - "my-entity", |
27 | | - description="My entity", |
28 | | - value_type=ValueType.STRING, |
29 | | - tags={"key1": "val1", "key2": "val2"}, |
30 | | - ) |
| 30 | + with pytest.deprecated_call(): |
| 31 | + entity = Entity( |
| 32 | + "my-entity", |
| 33 | + description="My entity", |
| 34 | + value_type=ValueType.STRING, |
| 35 | + tags={"key1": "val1", "key2": "val2"}, |
| 36 | + ) |
31 | 37 | assert "key1" in entity.tags.keys() and entity.tags["key1"] == "val1" |
32 | 38 | assert "key2" in entity.tags.keys() and entity.tags["key2"] == "val2" |
33 | 39 |
|
34 | 40 |
|
35 | 41 | def test_entity_without_tags_empty_dict(): |
36 | | - entity = Entity("my-entity", description="My entity", value_type=ValueType.STRING) |
| 42 | + with pytest.deprecated_call(): |
| 43 | + entity = Entity( |
| 44 | + "my-entity", description="My entity", value_type=ValueType.STRING |
| 45 | + ) |
37 | 46 | assert entity.tags == dict() |
38 | 47 | assert len(entity.tags) == 0 |
39 | 48 |
|
40 | 49 |
|
41 | 50 | def test_entity_without_description(): |
42 | | - Entity("my-entity", value_type=ValueType.STRING) |
| 51 | + with pytest.deprecated_call(): |
| 52 | + Entity("my-entity", value_type=ValueType.STRING) |
| 53 | + |
| 54 | + |
| 55 | +def test_name_not_specified(): |
| 56 | + assertpy.assert_that(lambda: Entity(value_type=ValueType.STRING)).raises(ValueError) |
| 57 | + |
| 58 | + |
| 59 | +def test_multiple_args(): |
| 60 | + assertpy.assert_that(lambda: Entity("a", "b", value_type=ValueType.STRING)).raises( |
| 61 | + ValueError |
| 62 | + ) |
| 63 | + |
| 64 | + |
| 65 | +def test_name_keyword(recwarn): |
| 66 | + Entity(name="my-entity", value_type=ValueType.STRING) |
| 67 | + assert len(recwarn) == 0 |
0 commit comments