def test_z_calculations(self): # Checks wether the atom can calculate stretched values: # 1. When everything is set up the way it should be: default_z = 9.0 lattice_d = 5.4 factor = 0.5 class DummyComponent(object): def get_interlayer_stretch_factors(self): return lattice_d, factor parent = DummyComponent() atom = Atom(parent=parent) atom.stretch_values = True atom.default_z = default_z z = atom.z self.assertEqual(z, lattice_d + (default_z - lattice_d) * factor) # 2. When no component is set, but stretched is True: should not raise an error, but simple ignore the stretching atom.parent = None z = atom.z
def test_z_calculations(self): # Checks wether the atom can calculate stretched values: # 1. When everything is set up the way it should be: default_z = 9.0 lattice_d = 5.4 factor = 0.5 parent = Mock() parent.configure_mock(**{ 'get_interlayer_stretch_factors.return_value': (lattice_d, factor) }) atom = Atom(parent=parent) atom.stretch_values = True atom.default_z = default_z z = atom.z self.assertEqual(z, lattice_d + (default_z - lattice_d) * factor) # 2. When no component is set, but stretched is True: should not raise an error, but simple ignore the stretching atom.parent = None z = atom.z