Beispiel #1
0
    def test_many_roles(self, db_session):
        people = PersonFactory.create_batch(4)
        roles = RoleFactory.create_batch(2)
        db_session.flush()

        people[0].roles.append(roles[0])
        people[1].roles.append(roles[1])
        people[3].roles.append(roles[1])
        db_session.flush()

        p1 = Person.find_by_id(people[0].id, abort_404=False)
        p2 = Person.find_by_id(people[1].id, abort_404=False)
        p3 = Person.find_by_id(people[2].id, abort_404=False)
        p4 = Person.find_by_id(people[3].id, abort_404=False)
        r1 = Role.find_by_id(roles[0].id, abort_404=False)
        r2 = Role.find_by_id(roles[1].id, abort_404=False)

        assert r1 in p1.roles
        assert r2 in p2.roles
        assert r2 in p4.roles
        assert len(p3.roles) == 0

        assert r1 not in p2.roles
        assert r1 not in p3.roles
        assert r1 not in p4.roles
        assert r2 not in p1.roles
        assert r2 not in p3.roles
    def test_many_roles(self, db_session):
        people = PersonFactory.create_batch(4)
        roles  = RoleFactory.create_batch(2)
        db_session.flush()

        people[0].roles.append(roles[0])
        people[1].roles.append(roles[1])
        people[3].roles.append(roles[1])
        db_session.flush()
        
        p1 = Person.find_by_id(people[0].id, abort_404=False)
        p2 = Person.find_by_id(people[1].id, abort_404=False)
        p3 = Person.find_by_id(people[2].id, abort_404=False)
        p4 = Person.find_by_id(people[3].id, abort_404=False)
        r1 = Role.find_by_id(roles[0].id,    abort_404=False)
        r2 = Role.find_by_id(roles[1].id,    abort_404=False)


        assert r1 in p1.roles
        assert r2 in p2.roles
        assert r2 in p4.roles
        assert len(p3.roles) == 0

        assert r1 not in p2.roles
        assert r1 not in p3.roles
        assert r1 not in p4.roles
        assert r2 not in p1.roles
        assert r2 not in p3.roles
Beispiel #3
0
    def test_create(self, app, db_session):
        p = CompletePersonFactory(roles = [RoleFactory(name="organiser")])
        db_session.commit()

        do_login(app, p)
        resp = app.get(url_for(controller='role', action='new'))
        f = resp.form
        f['role.name']          = 'newrole'
        f['role.pretty_name']   = 'Test created role'
        f['role.comment']       = 'I understand why people generate this'
        f['role.display_order'] = 23
        resp = f.submit()
        resp = resp.follow() # Failure indicates form validation error

        assert 'Missing value' not in unicode(resp.body, 'utf-8')

        # Test creation
        db_session.expunge_all()

        roles = Role.find_all()
        assert len(roles) == 2 # organiser and created one

        new_role = roles[1] if roles[0].name == "organiser" else roles[0]

        assert new_role.name == 'newrole'
        assert new_role.pretty_name == 'Test created role'
        assert new_role.comment == 'I understand why people generate this'
        assert new_role.display_order == 23
Beispiel #4
0
    def test_map_person(self, db_session):
        """Test mapping persons to roles"""
        person = PersonFactory()
        role = RoleFactory()
        db_session.flush()

        person.roles.append(role)
        db_session.flush()

        person = Person.find_by_id(person.id, abort_404=False)
        role = Role.find_by_id(role.id, abort_404=False)

        assert role in person.roles
        assert person in role.people
    def test_map_person(self, db_session):
        """Test mapping persons to roles"""
        person = PersonFactory()
        role = RoleFactory()
        db_session.flush()

        person.roles.append(role)
        db_session.flush()

        person = Person.find_by_id(person.id, abort_404=False)
        role = Role.find_by_id(role.id, abort_404=False)

        assert role in person.roles
        assert person in role.people
Beispiel #6
0
def test_default_roles():
    roles = Role.find_all()
    print roles
    assert False