Skip to content

Commit

Permalink
add more unit test for Reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Apr 3, 2024
1 parent 656141a commit 48ba33e
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions tests/data/test_reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,36 @@ def test_init(self):
}
products = {Species("COOH", -7, True, 3.5): 1}

reactionstep = ReactionStep(reactants, products)
reactionstep_0 = ReactionStep(reactants, products)

reactionstep_1 = ReactionStep(
products, reactants
) # pylint: disable=W1114

reaction = Reaction([reactionstep_0, reactionstep_1])

assert isinstance(reaction, Reaction)

# Test assign item
reaction[1] = reactionstep_0
assert reaction[0] == reaction[1]

_reaction = Reaction([reactionstep])
def test_invalid_steps(self):
"""Test property: steps."""

assert isinstance(_reaction, Reaction)
# Invalid ReactionStep dtype
with pytest.raises(
TypeError, match="Each step should be ReactionStep"
):
Reaction(["Step"])

# Duplicate steps
reactants = {Species("CO2", -6, True, 3.0): 1}
products = {Species("COOH", -7, True, 3.5): 1}

reactionstep = ReactionStep(reactants, products)
with pytest.raises(ValueError, match="Duplicate ReactionStep found"):
Reaction([reactionstep, reactionstep])

def test_from_str(self):
test_str = """
Expand Down

0 comments on commit 48ba33e

Please sign in to comment.