Ejemplo n.º 1
0
    def test_dot_dict_set_multiple_times(self):
        state = DotDictState()
        state.hi = 'hi'
        assert state.hi == 'hi'

        state.bye = {}
        state.bye.foo = 'test'
        assert state.bye.foo == 'test'
        state.bye.foo = 'bar'
        assert state.bye.foo == 'bar'
Ejemplo n.º 2
0
    def test_real_deep_dot_dict_set_and_get(self):
        state = DotDictState({'test': {'dict': 'val'}})
        state.test.more = {'lets': {'go': {'deeper': 'yeah!'}}}
        state.test.more = {'another': ['test', 'here', 'we', 'go']}

        assert state.test.more.lets.go.deeper == 'yeah!'
        assert state.test.more.another == ['test', 'here', 'we', 'go']

        with pytest.raises(KeyError):
            state.test.more.not_here
Ejemplo n.º 3
0
 def test_nested_dot_get(self):
     state = DotDictState({'test': {'dict': 'val'}})
     assert state.test.get('dict') == 'val'
Ejemplo n.º 4
0
    def test_state_get(self):
        state = DotDictState({'test': 'dumb'})
        val = state.get('test')

        assert val == 'dumb'
        assert state.to_dict() == {'test': 'dumb'}
Ejemplo n.º 5
0
 def test_state_dot(self):
     state = DotDictState({'test': {'dict': 'val'}})
     assert state.test.dict == 'val'
Ejemplo n.º 6
0
    def test_state_update(self):
        state = DotDictState({'test': 'dumb'})
        state.update({'oops': 'my bad'})

        assert state.to_dict() == {'oops': 'my bad', 'test': 'dumb'}
Ejemplo n.º 7
0
 def test_state_to_dict(self):
     state = DotDictState({'test': {'dict': 'val'}})
     d = state.to_dict()
     assert d == {'test': {'dict': 'val'}}
Ejemplo n.º 8
0
    def test_dot_dict_in(self):
        state = DotDictState({'test': {'dict': 'val'}})

        assert 'test' in state
        assert 'dict' in state.test
Ejemplo n.º 9
0
 def test_deep_access_without_items(self):
     state = DotDictState({'test': {'dict': 'val'}})
     with pytest.raises(KeyError):
         state.test.nothing.can.be.found.here
Ejemplo n.º 10
0
    def test_dot_dict_state_in_workflow(self):
        workflow = Workflow(state=DotDictState({'value': 3}))
        workflow.current_step = SecondStep()
        workflow.execute_step()

        assert workflow.state.state == {'value': 6}