def test_permissions(): class App(morepath.App): pass class A(object): pass @App.path(path='/foo', model=A) def get_a(): return A() class ReadPermission(object): pass @App.view(model=A, permission=ReadPermission) def a_default(self, request): pass App.commit() infos = get_path_and_view_info(App) for info in infos: info['filename'] = 'flurb.py' info['lineno'] = 17 f = io() format_csv(f, 'excel', infos) s = f.getvalue() assert s == '''\
def test_internal_view(): class App(morepath.App): pass class A(object): pass @App.path(path='/foo', model=A) def get_a(): return A() @App.view(model=A, name='bar', internal=True) def a_default(self, request): return "default" App.commit() infos = get_path_and_view_info(App) infos[0]['filename'] = 'flurb.py' infos[0]['lineno'] = 17 infos[1]['filename'] = 'flurb.py' infos[1]['lineno'] = 20 f = io() format_csv(f, 'excel', infos) s = f.getvalue() assert s == '''\
def test_extra_predicates(): class App(morepath.App): pass class A(object): pass class B(object): pass @App.path(path='/foo', model=A) def get_a(): return A() @App.view(model=A, body_model=B, request_method='POST') def post_a(self, request): return A() App.commit() infos = get_path_and_view_info(App) for info in infos: info['filename'] = 'flurb.py' info['lineno'] = 17 f = io() format_csv(f, 'excel', infos) s = f.getvalue() assert s == '''\
def test_format_csv_europe_delimiter(): infos = [{ u'path': u'/foo', u'directive': u'path', u'filename': u'flurb.py', u'lineno': 17, }, { u'path': u'/muchlonger', u'directive': u'path', u'filename': u'flurb2.py', u'lineno': 28, }, { u'path': u'/muchlonger/+edit', u'directive': u'view', u'filename': u'flurb3.py', u'lineno': 1, u'permission': 'public', u'view_name': 'edit', }, { u'path': u'internal', u'directive': u'view', u'filename': u'flurb3.py', u'lineno': 4, u'permission': 'internal', u'view_name': 'something', }] f = io() format_csv(f, 'europe', infos) s = f.getvalue() assert s == '''\
def test_absorb(): class App(morepath.App): pass class A(object): pass @App.path(path='/foo', model=A, absorb=True) def get_a(): return A() App.commit() infos = get_path_and_view_info(App) infos[0]['filename'] = 'flurb.py' infos[0]['lineno'] = 17 f = io() format_csv(f, 'excel', infos) s = f.getvalue() assert s == '''\
def test_sort_paths_and_views(): class App(morepath.App): pass class A(object): pass class B(object): pass @App.path(path='/a', model=A) def get_a(): return A() @App.path(path='/b', model=B) def get_b(): return B() @App.view(model=A) def a_default(self, request): return "default" @App.view(model=A, name='x') def a_x(self, request): return "x" @App.view(model=A, name='y') def a_y(self, request): return "y" @App.view(model=A, name='y', request_method='POST') def a_y_post(self, request): return 'y' @App.view(model=A, name='y', request_method='PUT') def a_y_put(self, request): return 'y' @App.view(model=A, name='y', request_method='DELETE') def a_y_delete(self, request): return 'y' @App.view(model=A, name='z') def a_z(self, request): return 'y' @App.view(model=A, name='i', internal=True) def a_internal(self, request): return 'i' @App.view(model=B) def b_default(self, request): return 'b' App.commit() infos = get_path_and_view_info(App) for info in infos: info['filename'] = 'flurb.py' info['lineno'] = 17 f = io() format_csv(f, 'excel', infos) s = f.getvalue() assert s == '''\