Skip to content

Commit

Permalink
Added tests for observables
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalshaikh42 committed Jul 19, 2018
1 parent 8e0147a commit d4aeaba
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
59 changes: 59 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,3 +978,62 @@ def test_ReactionParticipantAttribute(self):
self.assertEqual(result[0], None)
self.assertEqual(
result[1].messages[0], 'Incorrectly formatted participants: ==> prot1[c]')


class ObservableCoefficientTestCase(unittest.TestCase):
def test_observable_coefficient(self):
pass

def test_serialize(self):
pass

def test_deserialize(self):
pass


class ObservableTestCase(unittest.TestCase):
def setUp(self):
pass

def test_observables(self):
cell = core.Cell()
comp1 = core.Compartment(id='c')
prot1 = core.ProteinSpeciesType(id='prot1')
prot2 = core.ProteinSpeciesType(id='prot2')
rna1 = core.RnaSpeciesType(id="rna1")
rna2 = core.RnaSpeciesType(id='rna2')

species1 = core.Species(species_type=prot1, compartment=comp1)
species2 = core.Species(species_type=rna1, compartment=comp1)

speciesCoefficient1 = core.SpeciesCoefficient(
species=species1, coefficient=2)
speciesCoefficient2 = core.SpeciesCoefficient(
species=species2, coefficient=3)

observable1 = core.Observable(
cell=cell, species=[speciesCoefficient1, speciesCoefficient2])
observableCoefficinet1 = core.ObservableCoefficient(
observable=observable1, coefficient=2)

observable2 = core.Observable(cell=cell, species=[
speciesCoefficient1, speciesCoefficient2], observables=[observableCoefficinet1])

self.assertIsInstance(observable1, core.Observable)
self.assertIsInstance(observable2, core.Observable)
with self.assertRaisesRegex(AttributeError, ""):
observable3 = core.Observable(
cell=cell, species=[species1, species2])
self.assertIsInstance(observable1.species[0], core.SpeciesCoefficient)
self.assertIsInstance(
observable2.observables[0], core.ObservableCoefficient)
self.assertIsInstance(
observable1.species[0].species, core.Species)
self.assertEqual(observable1.species[0].species.id(), 'prot1[c]')
self.assertEqual(
observable1.species[1].species.species_type.id, 'rna1')
self.assertIsInstance(
observable2.observables[0].observable, core.Observable)

def test_obervables(self):
pass
5 changes: 3 additions & 2 deletions wc_kb/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
""" Schema to represent a knowledge base to build models
:Author: Bilal Shaikh <bilal.shaikh@columbia.edu>
:Author: Balazs Szigeti <balazs.szigeti@mssm.edu>
:Author: Jonathan Karr <jonrkarr@gmail.com>
:Author: Bilal Shaikh <bilal.shaikh@columbia.edu>
:Date: 2018-02-07
:Copyright: 2018, Karr Lab
:License: MIT
Expand Down Expand Up @@ -1111,7 +1112,7 @@ class Observable(KnowledgeBaseObject):
species = ObservableSpeciesParticipantAttribute(
'SpeciesCoefficient', related_name='observables')
observables = ObservableObservableParticipantAttribute(
'ObservableCoefficient', related_name='observable')
'ObservableCoefficient', related_name='observables')

class Meta(obj_model.Model.Meta):
attribute_order = ('id', 'name', 'cell', 'species',
Expand Down

0 comments on commit d4aeaba

Please sign in to comment.