def res_simple(): parent = Mock(name='parent') parent.request.app = MagicMock(name='app') parent.app = parent.request.app name = 'name' return Resource(parent, name)
def test_Resource_init__root(): # noqa name = 'root' res = Resource(None, name) assert res.__parent__ is None assert res.name == name assert res.app is None assert res.setup is None
def test_Resource_init(): # noqa parent = Mock(name='parent', __parent__=None) app = MagicMock(name='app') app.router.resources = {} parent.request.app = parent.app = app name = 'name' res = Resource(parent, name) assert res.__parent__ is parent assert res.name == name assert res.app is parent.request.app assert res.setup is res.app.router.resources.get(Resource)