@pytest.mark.django_db
def test_no_root_view_permissions(po_directory, nobody, default, admin, view, no_permission_sets, no_projects, project_foo, project_bar):
 ALL_PROJECTS = [project_foo.code, project_bar.code]
 foo_user = UserFactory.create(username='foo')
 bar_user = UserFactory.create(username='bar')
 _require_permission_set(foo_user, project_foo.directory, [view])
 assert items_equal(Project.accessible_by_user(admin), ALL_PROJECTS)
 assert items_equal(Project.accessible_by_user(foo_user), [project_foo.code])
 assert items_equal(Project.accessible_by_user(bar_user), [])
 assert items_equal(Project.accessible_by_user(default), [])
 assert items_equal(Project.accessible_by_user(nobody), [])
 _require_permission_set(default, project_bar.directory, [view])
 assert items_equal(Project.accessible_by_user(admin), ALL_PROJECTS)
 assert items_equal(Project.accessible_by_user(foo_user), ALL_PROJECTS)
 assert items_equal(Project.accessible_by_user(bar_user), [project_bar.code])
 assert items_equal(Project.accessible_by_user(default), [project_bar.code])
 assert items_equal(Project.accessible_by_user(nobody), [])

@ pytest . mark . django_db def test_no_root_view_permissions ( po_directory , nobody , default , admin , view , no_permission_sets , no_projects , project_foo , project_bar ) : ALL_PROJECTS = [ project_foo . code , project_bar . code ] foo_user = UserFactory . create ( username = 'foo' ) bar_user = UserFactory . create ( username = 'bar' ) _require_permission_set ( foo_user , project_foo . directory , [ view ] ) assert items_equal ( Project . accessible_by_user ( admin ) , ALL_PROJECTS ) assert items_equal ( Project . accessible_by_user ( foo_user ) , [ project_foo . code ] ) assert items_equal ( Project . accessible_by_user ( bar_user ) , [ ] ) assert items_equal ( Project . accessible_by_user ( default ) , [ ] ) assert items_equal ( Project . accessible_by_user ( nobody ) , [ ] ) _require_permission_set ( default , project_bar . directory , [ view ] ) assert items_equal ( Project . accessible_by_user ( admin ) , ALL_PROJECTS ) assert items_equal ( Project . accessible_by_user ( foo_user ) , ALL_PROJECTS ) assert items_equal ( Project . accessible_by_user ( bar_user ) , [ project_bar . code ] ) assert items_equal ( Project . accessible_by_user ( default ) , [ project_bar . code ] ) assert items_equal ( Project . accessible_by_user ( nobody ) , [ ] )
tests user-accessible projects when there are no permissions set at the root .