Remove sticky list alias, fix instance default state
This commit is contained in:
@@ -318,8 +318,42 @@ class TestState(unittest.TestCase):
|
||||
states = State(2, default_state='FOO')
|
||||
with self.assertRaises(StateItemNotFound):
|
||||
states.state('NEW')
|
||||
getattr(states, 'FOO')
|
||||
r = getattr(states, 'FOO')
|
||||
self.assertEqual(r, 0)
|
||||
states.state('FOO')
|
||||
states.put('bar')
|
||||
r = states.list(states.FOO)
|
||||
print(r)
|
||||
self.assertEqual(len(r), 1)
|
||||
|
||||
|
||||
def test_unset(self):
|
||||
states = State(2)
|
||||
states.add('one')
|
||||
states.add('two')
|
||||
states.alias('three', states.ONE, states.TWO)
|
||||
states.put('foo', state=states.ONE)
|
||||
states.set('foo', states.TWO)
|
||||
r = states.list(states.ONE)
|
||||
self.assertEqual(len(r), 1)
|
||||
r = states.list(states.TWO)
|
||||
self.assertEqual(len(r), 1)
|
||||
r = states.unset('foo', states.ONE)
|
||||
r = states.list(states.ONE)
|
||||
self.assertEqual(len(r), 0)
|
||||
r = states.list(states.TWO)
|
||||
self.assertEqual(len(r), 1)
|
||||
|
||||
|
||||
def test_move(self):
|
||||
states = State(1)
|
||||
states.add('one')
|
||||
states.put('foo')
|
||||
r = states.list(states.NEW)
|
||||
self.assertEqual(len(r), 1)
|
||||
states.move('foo', states.ONE)
|
||||
r = states.list(states.NEW)
|
||||
self.assertEqual(len(r), 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -8,7 +8,7 @@ from shep.error import (
|
||||
)
|
||||
|
||||
|
||||
def mock_verify(state, from_state, to_state):
|
||||
def mock_verify(state, key, from_state, to_state):
|
||||
if from_state == state.FOO:
|
||||
if to_state == state.BAR:
|
||||
return 'bar cannot follow foo'
|
||||
|
||||
Reference in New Issue
Block a user