예제 #1
0
    def test_states(self):
        # empty state
        s = AxisState()
        self.assertEquals(s, "UNKNOWN")

        # moving
        s.set("MOVING")
        self.assertEquals(s, "MOVING")

        # moving => not ready
        self.assertFalse(s.READY)

        # now ready but no more moving
        s.set("READY")
        self.assertTrue(s.READY)
        self.assertFalse(s.MOVING)

        # custom state
        s.create_state("PARKED", "c'est ma place !!")
        s.set("PARKED")
        # still ready
        self.assertTrue(s.READY)
        self.assertEquals(s, "PARKED")

        # Prints string of states.
        self.assertTrue(isinstance(s.current_states(), str))

        # bad name for a state
        self.assertRaises(ValueError, s.create_state, "A bad state")
예제 #2
0
 def test_from_current_states_str(self):
     s = AxisState(("KAPUT", "auff"), "LIMNEG", "READY")
     states_str = s.current_states()
     t = AxisState(states_str)
     self.assertTrue(t.READY)
     self.assertEquals(t._state_desc["KAPUT"], "auff")
     self.assertEquals(t._state_desc["LIMNEG"], "Hardware low limit active")
     self.assertEquals(s.current_states(), t.current_states())
     u = AxisState()
     v = AxisState(u.current_states())
     self.assertEquals(u.current_states(), v.current_states())
예제 #3
0
def test_from_current_states_str():
    s = AxisState(("KAPUT", "auf"), "LIMNEG", "READY")
    states_str = s.current_states()
    t = AxisState(states_str)
    assert t.READY
    assert t._state_desc["KAPUT"] == "auf"
    assert t._state_desc["LIMNEG"] == "Hardware low limit active"
    assert s.current_states() == t.current_states()
    u = AxisState()
    v = AxisState(u.current_states())
    assert u.current_states() == v.current_states()
예제 #4
0
 def test_state_from_state(self):
     s = AxisState("READY")
     t = AxisState(s)
     self.assertEquals(s.current_states(), t.current_states())
예제 #5
0
def test_state_from_state():
    s = AxisState("READY")
    t = AxisState(s)
    assert s.current_states() == t.current_states()
예제 #6
0
def test_state_print():
    s = AxisState()

    s.set("READY")
    assert isinstance(s.current_states(), str)