# -*- coding: utf-8 -*-
"""Test functions of metabolite.py"""
import pytest
from cobra.core import Metabolite
[docs]def test_set_id(solved_model):
solution, model = solved_model
met = Metabolite("test")
with pytest.raises(TypeError):
setattr(met, "id", 1)
model.add_metabolites([met])
with pytest.raises(ValueError):
setattr(met, "id", "g6p_c")
met.id = "test2"
assert "test2" in model.metabolites
assert "test" not in model.metabolites
[docs]def test_remove_from_model(solved_model):
solution, model = solved_model
met = model.metabolites.get_by_id("g6p_c")
met.remove_from_model()
assert not (met.id in model.metabolites)
assert not (met.id in model.constraints)
[docs]def test_repr_html_(model):
assert "<table>" in model.metabolites.h2o_c._repr_html_()