def test_connec_method(self): self.unit1 = SiamObj(1, 2, q=12) self.unit2 = SiamObj(1, 2, z=4) self.unit3 = SiamObj(1, 2, z=4) self.unit1.connect(1, 2, z=4).z = 100 self.assertEqual(self.unit2.z, 100) self.assertEqual(self.unit3.z, 100)
def test_delete(self): unit1 = SiamObj('1', '2', a=1) unit2 = SiamObj('1', '2', a=1) unit3 = SiamObj('2', '2', a=1) pool = unit3.pool self.assertEqual(2, len(pool), 'Wrong number of instances of SiamObj class') del unit3 self.assertEqual(1, len(pool), "Delete didn't work")
def test_connect(self): unit1 = SiamObj('1', '2', a=1) unit2 = SiamObj('1', '2', a=1) unit3 = SiamObj('2', '2', a=1) unit3.connect('1', '2', 1).a = 2 self.assertEqual(2, unit1.a, 'Attribute of instance is not assigned to value') self.assertEqual(2, unit2.a, 'Attribute of instance is not assigned to value')
class SiamMetaTest(unittest.TestCase): def test_equal(self): self.unit1 = SiamObj("1", 22, c=33) self.unit2 = SiamObj("1", 22, c=33) self.assertEqual(self.unit1, self.unit2) def test_not_equal(self): self.unit1 = SiamObj("1", 22, d=33) self.unit2 = SiamObj("1", d=33) self.unit3 = SiamObj(0, "11", p=15) self.assertNotEqual(self.unit1, self.unit3) self.assertNotEqual(self.unit1, self.unit2) def test_connec_method(self): self.unit1 = SiamObj(1, 2, q=12) self.unit2 = SiamObj(1, 2, z=4) self.unit3 = SiamObj(1, 2, z=4) self.unit1.connect(1, 2, z=4).z = 100 self.assertEqual(self.unit2.z, 100) self.assertEqual(self.unit3.z, 100) def test_pool_method(self): self.unit2 = SiamObj(a=2) self.unit3 = SiamObj(a=3) pool = self.unit3.pool del self.unit3 self.assertEqual(len(pool), 1)
def test_equal(self): self.unit1 = SiamObj("1", 22, c=33) self.unit2 = SiamObj("1", 22, c=33) self.assertEqual(self.unit1, self.unit2)
def test_pool_method(self): self.unit2 = SiamObj(a=2) self.unit3 = SiamObj(a=3) pool = self.unit3.pool del self.unit3 self.assertEqual(len(pool), 1)
def test_not_equal(self): self.unit1 = SiamObj("1", 22, d=33) self.unit2 = SiamObj("1", d=33) self.unit3 = SiamObj(0, "11", p=15) self.assertNotEqual(self.unit1, self.unit3) self.assertNotEqual(self.unit1, self.unit2)
def test_not_same_instance(self): unit1 = SiamObj('1', '2', a=1) unit3 = SiamObj('2', '2', a=1) self.assertNotEqual(unit1, unit3, 'Must not be the same instance')
def test_same_instance(self): unit1 = SiamObj('1', '2', a=1) unit2 = SiamObj('1', '2', a=1) self.assertEqual(unit1, unit2, 'Must be the same instance')
def test_notEqual(self): unit1 = SiamObj('1', '2', a=1) unit3 = SiamObj('2', '2', a=1) self.assertNotEqual(unit1, unit3)
def test_isEqual(self): unit1 = SiamObj('1', '2', a=1) unit2 = SiamObj('1', '2', a=1) self.assertEqual(unit1, unit2)