예제 #1
0
파일: Test.py 프로젝트: sybila/BCSgen
 def setUp(self):
     self.Aagent1 = Atomic_Agent('S', ['p'], 'cyt')
     self.Aagent12 = Atomic_Agent('S', ['u'], 'cyt')
     self.Aagent2 = Atomic_Agent('T', ['u'], 'cyt')
     self.Aagent22 = Atomic_Agent('T', ['p'], 'cyt')
     self.Aagent3 = Atomic_Agent('S', ['u', 'p'], 'cyt')
     self.Aagent4 = Atomic_Agent('T', ['u', 'p'], 'cyt')
     self.Aagent5 = Atomic_Agent('S', ['p'], 'cyt')
예제 #2
0
파일: Test.py 프로젝트: sybila/BCSgen
class TestAtomicAgent(unittest.TestCase):
    def setUp(self):
        self.Aagent1 = Atomic_Agent('S', ['p'], 'cyt')
        self.Aagent12 = Atomic_Agent('S', ['u'], 'cyt')
        self.Aagent2 = Atomic_Agent('T', ['u'], 'cyt')
        self.Aagent22 = Atomic_Agent('T', ['p'], 'cyt')
        self.Aagent3 = Atomic_Agent('S', ['u', 'p'], 'cyt')
        self.Aagent4 = Atomic_Agent('T', ['u', 'p'], 'cyt')
        self.Aagent5 = Atomic_Agent('S', ['p'], 'cyt')

    def test_print(self):
        self.assertEqual(self.Aagent1.__str__(), 'S{p}::cyt')
        self.assertEqual(self.Aagent3.__str__(), 'S::cyt')

    def test_equal(self):
        self.assertTrue(self.Aagent1.__eq__(self.Aagent1))
        self.assertTrue(self.Aagent3.__eq__(Atomic_Agent('S', ['p', 'u'], 'cyt')))
        self.assertFalse(self.Aagent2.__eq__(self.Aagent1))
        self.assertTrue(self.Aagent1.__eq__(self.Aagent5))
        self.assertFalse(self.Aagent1 != self.Aagent5)

    def test_isCompatibleWith(self):
        self.assertTrue(self.Aagent1.isCompatibleWith(self.Aagent3))
        self.assertFalse((self.Aagent3.isCompatibleWith(self.Aagent1)))
        self.assertFalse((self.Aagent3.isCompatibleWith(self.Aagent4)))
        self.assertTrue((self.Aagent2.isCompatibleWith(self.Aagent2)))

    def test_hash(self):
        self.assertEqual(hash(self.Aagent3), hash(Atomic_Agent('S', ['p', 'u'], 'cyt')))
        self.assertNotEqual(hash(self.Aagent1), hash(self.Aagent3))

    def test_setter(self):
        self.Aagent1.setStates(['u'])
        self.assertTrue(self.Aagent1.__eq__(self.Aagent12))
        self.Aagent2.setCompartment('cell')
        self.assertTrue(self.Aagent2.__eq__(Atomic_Agent('T', ['u'], 'cell')))

    def test_comparing(self):
        self.assertFalse(self.Aagent3 > self.Aagent1)
        self.assertTrue(self.Aagent3 < self.Aagent4)

    def test_equalNames(self):
        self.assertTrue(self.Aagent1.equalNames(self.Aagent12))