File: test_group.py

package info (click to toggle)
python-cobra 0.29.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,512 kB
  • sloc: python: 14,703; xml: 12,841; makefile: 137; sh: 32
file content (35 lines) | stat: -rw-r--r-- 1,156 bytes parent folder | download
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
"""Test functions of group via model.py."""

import pytest

from cobra import Model
from cobra.core import Group


def test_group_add_elements(model: Model) -> None:
    """Test adding elements to a group."""
    num_members = 5
    reactions_for_group = model.reactions[0:num_members]
    group = Group("arbitrary_group1")
    group.add_members(reactions_for_group)
    group.kind = "collection"
    # number of member sin group should equal the number of reactions
    # assigned to the group
    assert len(group.members) == num_members

    # Choose an overlapping, larger subset of reactions for the group
    num_total_members = 12
    reactions_for_larger_group = model.reactions[0:num_total_members]
    group.add_members(reactions_for_larger_group)
    assert len(group.members) == num_total_members


def test_group_kind() -> None:
    """Test SBML compliance and group kind."""
    group = Group("arbitrary_group1")
    with pytest.raises(ValueError) as excinfo:
        group.kind = "non-SBML compliant group kind"
    assert "Kind can only by one of:" in str(excinfo.value)

    group.kind = "collection"
    assert group.kind == "collection"