forked from microsoft/durabletask-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_entity_id_parsing.py
More file actions
53 lines (39 loc) · 1.52 KB
/
Copy pathtest_entity_id_parsing.py
File metadata and controls
53 lines (39 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import pytest
from durabletask.entities import EntityInstanceId
def test_entity_id_parsing_success():
entity_id_str = "@MyEntity@TestInstance"
entity_id = EntityInstanceId.parse(entity_id_str)
assert entity_id.entity == "myentity" # should be case-insensitive (lowercased)
assert entity_id.key == "TestInstance"
assert str(entity_id) == "@myentity@TestInstance"
def test_is_entity_id_name_case_insensitive():
id1 = EntityInstanceId("MyEntity", "instance1")
id2 = EntityInstanceId("myentity", "instance1")
assert id1 == id2
def test_entity_id_parsing_failures():
# Test empty string
with pytest.raises(ValueError):
EntityInstanceId.parse("")
# Test invalid entity id format
with pytest.raises(ValueError):
EntityInstanceId.parse("invalidEntityId")
# Test single @
with pytest.raises(ValueError):
EntityInstanceId.parse("@")
# Test double @
with pytest.raises(ValueError):
EntityInstanceId.parse("@@")
# Test @ with invalid placement
with pytest.raises(ValueError):
EntityInstanceId.parse("@invalid@")
# Test @@ at end
with pytest.raises(ValueError):
EntityInstanceId.parse("@@invalid")
# Test symbol in wrong position
with pytest.raises(ValueError):
EntityInstanceId.parse("invalid@symbolplacement")
# Test multiple @ symbols
with pytest.raises(ValueError):
EntityInstanceId.parse("invalid@symbol@placement")