Exemplo n.º 1
0
def test_resources_with_same_name():
    """
    ensure we don't have any IndexErrors or whatever
    """
    with resources.user_ctx():
        with resources.user_ctx():
            pass
Exemplo n.º 2
0
def test_resources_with_same_name():
    """
    ensure we don't have any IndexErrors or whatever
    """
    with resources.user_ctx():
        with resources.user_ctx():
            pass
Exemplo n.º 3
0
def test_context_manager_and_two_resources():
    with resources.user_ctx(name='Mary Moe', _name='mary'):
        with resources.user_ctx(name='John Doe', _name='john'):
            # get resources by names
            assert resources.john == {'name': 'John Doe'}
            assert resources.mary == {'name': 'Mary Moe'}
            # get resources by keys
            assert resources['john'] == {'name': 'John Doe'}
            assert resources['mary'] == {'name': 'Mary Moe'}
Exemplo n.º 4
0
def test_context_manager_and_two_resources():
    with resources.user_ctx(name='Mary Moe', _name='mary'):
        with resources.user_ctx(name='John Doe', _name='john'):
            # get resources by names
            assert resources.john == {'name': 'John Doe'}
            assert resources.mary == {'name': 'Mary Moe'}
            # get resources by keys
            assert resources['john'] == {'name': 'John Doe'}
            assert resources['mary'] == {'name': 'Mary Moe'}
Exemplo n.º 5
0
def test_dependent_resources():
    with resources.user_ctx():
        with resources.todo_item_ctx():
            assert resources.todo_item['user'] == resources['user']
Exemplo n.º 6
0
def test_context_manager_and_different_user_name():
    assert not hasattr(resources, 'user')
    with resources.user_ctx(name='Mary Moe'):
        assert resources.user == {'name': 'Mary Moe'}
    assert not hasattr(resources, 'user')
Exemplo n.º 7
0
def test_context_manager():
    assert not hasattr(resources, 'user')
    with resources.user_ctx():
        assert resources.user == {'name': 'John Doe'}
    assert not hasattr(resources, 'user')
Exemplo n.º 8
0
def test_dependent_resources():
    with resources.user_ctx():
        with resources.todo_item_ctx():
            assert resources.todo_item['user'] == resources['user']
Exemplo n.º 9
0
def test_context_manager_and_different_user_name():
    assert not hasattr(resources, 'user')
    with resources.user_ctx(name='Mary Moe'):
        assert resources.user == {'name': 'Mary Moe'}
    assert not hasattr(resources, 'user')
Exemplo n.º 10
0
def test_context_manager():
    assert not hasattr(resources, 'user')
    with resources.user_ctx():
        assert resources.user == {'name': 'John Doe'}
    assert not hasattr(resources, 'user')