def setUp(self): self.atom = atom.Atom(type=self.type) self.child_atom = atom.Atom(type=self.child_type)
def testDataIsNotEqual(self): self.atom.write(self.content) other = atom.Atom(type=self.type) self.assertNotEqual(other, self.atom)
def testDataIsEqual(self): equal_atom = atom.Atom(type=self.type) self.assertEqual(equal_atom, self.atom)
def testDataIsNotEqual(self): inequal_atom = atom.Atom(type='ftyp') self.assertNotEqual(inequal_atom, self.atom)
def testGetChildrenOfType(self): loaded_atom = atom.Atom(self.atom_stream) children_of_type = loaded_atom.get_children_of_type(self.child_1_type) self.assertEqual(1, len(children_of_type)) self.assertEqual(loaded_atom[0], children_of_type[0])
def testContainerIsEqual(self): equal_atom = atom.Atom(type=self.type) self.assertEqual(equal_atom, self.atom)
def testLoadedAtomIsCorrectlyStructured(self): loaded_atom = atom.Atom(self.atom_stream) self.assertEqual(2, len(loaded_atom)) self.assertEqual(2, len(loaded_atom[0])) self.assertEqual(0, len(loaded_atom[1]))
def testReadDataAtom(self): loaded_atom = atom.Atom(self.atom_stream) loaded_atom[0][0].seek(0) self.assertEqual(self.child_1_1_data, loaded_atom[0][0].read())
def testAtomHasChild(self): loaded_atom = atom.Atom(self.atom_stream) self.assertEqual(1, len(loaded_atom))
def testAtomCanLoad(self): loaded_atom = atom.Atom(self.atom_stream)
def testSetItemOnlyAcceptsAtoms(self): self.atom.append(atom.Atom(type='free')) self.assertRaises(TypeError, self.atom.__setitem__, 0, None)
def testContainerIsNotEqual(self): child_atoms = [self.child_atom, self.second_child_atom] self.atom[0:] = child_atoms other = atom.Atom(type=self.type) self.assertNotEqual(other, self.atom)
display_width = 900 display_height = 700 nucleon_radius = 5 electron_radius = 1 black = (0, 0, 0) white = (255, 255, 255) blue = (0, 0, 255) red = (255, 0, 0) prots = input("Protons: ") neuts = input("Neutrons: ") elecs = input("Electrons: ") userAtom = atom.Atom(prots, elecs, neuts) gameDisplay = pygame.display.set_mode((display_width, display_height)) pygame.display.set_caption('Atomic Model') clock = pygame.time.Clock() def proton(prx, pry, prr, color=blue): pygame.draw.circle(gameDisplay, black, (int(prx), int(pry)), prr + 2, 2) pygame.draw.circle(gameDisplay, color, (int(prx), int(pry)), prr) def electron(elecx, elecy, elecr, color=red): pygame.draw.circle(gameDisplay, black, (int(elecx), int(elecy)), elecr + 1, 1) pygame.draw.circle(gameDisplay, color, (int(elecx), int(elecy)), elecr)