def test_equality_condition(self): """testing the equality condition of a particle instance; a particle should only be equal to itself """ particle1 = base_classes.Particle(x=0, y=0, inclination=0) particle2 = base_classes.Particle(x=0, y=0, inclination=0) self.assertNotEqual(particle1, particle2)
def test_ascending_particle_number(self): """testing if the particle number increases correctly by instantiating new ones """ particle1 = base_classes.Particle(x=0, y=0, inclination=0) particle2 = base_classes.Particle(x=1, y=1, inclination=0) self.assertEqual(particle1.num + 1, particle2.num)
def test_descending_particle_number(self): """testing if the 'last_num' class attribute decreases by deleting a particle and a new instance gets its number correctly """ particle1 = base_classes.Particle(x=0, y=0, inclination=0) particle2 = base_classes.Particle(x=1, y=1, inclination=0) del particle2 self.assertEqual(base_classes.Particle.last_num, particle1.num + 1) particle3 = base_classes.Particle(x=1, y=1, inclination=0) self.assertEqual(particle1.num + 1, particle3.num)
def test_hashable(self): """testing if a generated particle is hashable or not """ particle = base_classes.Particle(x=0, y=0, inclination=0) s = {particle} self.assertTrue(s)
def test_box_num(self): """testing if a the 'box_num' method of a Particle instance generates the correct box number given its required arguments """ particle = base_classes.Particle(x=55, y=58, inclination=0) bn = particle.box_num(nc=100, box_length=10, box_width=10) self.assertEqual(bn, 505)