-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_rule_modifiers.py
More file actions
84 lines (69 loc) · 2.13 KB
/
test_rule_modifiers.py
File metadata and controls
84 lines (69 loc) · 2.13 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import pytest
from bionetgen.modelapi.xmlparsers import RuleBlockXML
def _rule_block_parser():
# Create a RuleBlockXML instance without running __init__ (which expects full rule XML)
return RuleBlockXML.__new__(RuleBlockXML)
def test_get_rule_mod_total_rate_string_true():
xml = {
"ListOfOperations": {},
"RateLaw": {
"@type": "Function",
"@totalrate": "1",
"@id": "r1",
"@name": "foo",
},
}
mod = _rule_block_parser().get_rule_mod(xml)
assert mod.type == "TotalRate"
assert mod.id == "r1"
assert mod.call == "1"
def test_get_rule_mod_delete_molecules_all_operations():
xml = {
"ListOfOperations": {
"Delete": [
{"@DeleteMolecules": "1"},
{"@DeleteMolecules": "1"},
]
}
}
mod = _rule_block_parser().get_rule_mod(xml)
assert mod.type == "DeleteMolecules"
def test_get_rule_mod_delete_molecules_missing_attribute_does_not_apply():
xml = {
"ListOfOperations": {
"Delete": [
{"@DeleteMolecules": "1"},
{},
]
}
}
mod = _rule_block_parser().get_rule_mod(xml)
assert mod.type is None
def test_get_rule_mod_move_connected_list_uses_each_element():
xml = {
"ListOfOperations": {
"ChangeCompartment": [
{
"@moveConnected": "1",
"@id": "a",
"@source": "s",
"@destination": "d",
"@flipOrientation": "0",
},
{
"@moveConnected": "1",
"@id": "b",
"@source": "s2",
"@destination": "d2",
"@flipOrientation": "1",
},
]
}
}
mod = _rule_block_parser().get_rule_mod(xml)
assert mod.type == "MoveConnected"
assert mod.id == ["a", "b"]
assert mod.source == ["s", "s2"]
assert mod.destination == ["d", "d2"]
assert mod.flip == ["0", "1"]
assert mod.call == ["1", "1"]