class TestReflectionList(object): def setup_method(self): self._geometry = SixCircleGammaOnArmGeometry() self.reflist = ReflectionList(self._geometry, ['a', 'd', 'g', 'o', 'c', 'p']) self.time = datetime.now() pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6) self.reflist.add_reflection(1, 2, 3, pos, 1000, "ref1", self.time) pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66) self.reflist.add_reflection(1.1, 2.2, 3.3, pos, 1100, "ref2", self.time) def test_add_reflection(self): assert len(self.reflist) == 2 def testGetReflection(self): answered = self.reflist.getReflection(1) pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6) desired = ([1, 2, 3], pos, 1000, "ref1", self.time) assert answered == desired def testRemoveReflection(self): self.reflist.removeReflection(1) answered = self.reflist.getReflection(1) pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66) desired = ([1.1, 2.2, 3.3], pos, 1100, "ref2", self.time) assert answered == desired def testedit_reflection(self): ps = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6) self.reflist.edit_reflection(1, 10, 20, 30, ps, 1000, "new1", self.time) assert (self.reflist.getReflection(1) == ([10, 20, 30], ps, 1000, "new1", self.time)) pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66) assert (self.reflist.getReflection(2) == ([1.1, 2.2, 3.3], pos, 1100, "ref2", self.time)) def testSwapReflection(self): self.reflist.swap_reflections(1, 2) pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66) assert (self.reflist.getReflection(1) == ([1.1, 2.2, 3.3], pos, 1100, "ref2", self.time)) pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6) assert (self.reflist.getReflection(2) == ([1, 2, 3], pos, 1000, "ref1", self.time)) def createRefStateDicts(self): ref_0 = { 'h': 1, 'k': 2, 'l': 3, 'position': (0.1, 0.2, 0.3, 0.4, 0.5, 0.6), 'energy': 1000, 'tag': "ref1", 'time': repr(self.time) } ref_1 = { 'h': 1.1, 'k': 2.2, 'l': 3.3, 'position': (0.11, 0.22, 0.33, 0.44, 0.55, 0.66), 'energy': 1100, 'tag': "ref2", 'time': repr(self.time) } return ref_0, ref_1