コード例 #1
0
def test_create_page(client, db_query, page_factory, logged_in_global_admin):
    data = factory.build(dict, FACTORY_CLASS=page_factory)
    res = client.get('/pages/+new')
    form = assert_deform(res)
    fill_form(form, data, ['name', 'lang', 'title', 'text'])

    with assert_difference(db_query(Page).count, 1):
        form.submit(status=302)
コード例 #2
0
def test_create_department(client, db_query, department_factory, logged_in_department_admin):
    data = factory.build(dict, FACTORY_CLASS=department_factory)
    res = client.get('/departments/+new')
    form = assert_deform(res)
    fill_form(form, data)

    with assert_difference(db_query(Department).count, 1):
        form.submit(status=302)
コード例 #3
0
def test_create_proposition_type(client, db_query, proposition_type_factory, logged_in_global_admin):
    data = factory.build(dict, FACTORY_CLASS=proposition_type_factory)
    res = client.get('/proposition_types/+new')
    form = assert_deform(res)
    fill_form(form, data, ['name', 'abbreviation'])

    with assert_difference(db_query(PropositionType).count, 1):
        form.submit(status=302)
コード例 #4
0
def test_create_policy(client, db_query, policy_factory,
                       logged_in_department_admin):
    data = factory.build(dict, FACTORY_CLASS=policy_factory)
    res = client.get('/policies/+new')
    form = assert_deform(res)
    fill_form(form, data, enum_field_names=['majority', 'voting_system'])

    with assert_difference(db_query(Policy).count, 1):
        form.submit(status=302)
コード例 #5
0
def test_create_customizable_text(client, db_query, customizable_text_factory,
                                  logged_in_global_admin):
    data = factory.build(dict, FACTORY_CLASS=customizable_text_factory)
    res = client.get('/customizable_texts/+new')
    form = assert_deform(res)
    fill_form(form, data, ['name', 'lang', 'text'])

    with assert_difference(db_query(CustomizableText).count, 1):
        form.submit(status=302)
コード例 #6
0
def test_create_voting_phase_type(client, db_query, voting_phase_type_factory,
                                  logged_in_global_admin):
    data = factory.build(dict, FACTORY_CLASS=voting_phase_type_factory)
    res = client.get('/voting_phase_types/+new')
    form = assert_deform(res)
    fill_form(form,
              data,
              field_names=[
                  'name', 'abbreviation', 'description',
                  'secret_voting_possible'
              ],
              enum_field_names=['voting_type'])

    with assert_difference(db_query(VotingPhaseType).count, 1):
        form.submit(status=302)
コード例 #7
0
def test_create_as_global_admin(db_query, client, voting_phase_factory,
                                voting_phase_type, logged_in_global_admin):
    """Global admin user should be able to update a voting phase regardless of department membership"""

    data = factory.build(dict, FACTORY_CLASS=voting_phase_factory)

    res = client.get('/v/+new')
    form = assert_deform(res)

    fill_form(form, data, ['title', 'name', 'secret', 'description'])
    form.set('date', data['target'], index=0)
    form['phase_type_id'] = voting_phase_type.id

    with assert_difference(db_query(VotingPhase).count, 1):
        form.submit(status=302)
コード例 #8
0
def test_create_voting_phase(client, db_query, voting_phase_type,
                             voting_phase_factory, logged_in_department_admin):
    data = factory.build(dict, FACTORY_CLASS=voting_phase_factory)
    department = logged_in_department_admin.managed_departments[0]

    res = client.get('/v/+new')
    form = assert_deform(res)

    fill_form(form, data, ['title', 'name', 'secret', 'description'])
    form.set('date', data['target'], index=0)
    form['department_id'] = department.id
    form['phase_type_id'] = voting_phase_type.id
    form['status'] = VotingStatus.PREPARING.name

    with assert_difference(db_query(VotingPhase).count, 1):
        form.submit(status=302)
コード例 #9
0
def test_create_document(client, db_query, document_factory,
                         proposition_type_factory, logged_in_department_admin):
    department = logged_in_department_admin.managed_departments[0]
    area = department.areas[0]
    proposition_type = proposition_type_factory()
    data = factory.build(dict, FACTORY_CLASS=document_factory)
    del data['area']
    data['area_id'] = area.id
    del data['proposition_type']
    data['proposition_type_id'] = proposition_type.id
    res = client.get('/documents/+new')
    form = assert_deform(res)
    fill_form(form, data)

    with assert_difference(db_query(Document).count, 1):
        form.submit(status=302)
コード例 #10
0
def test_create_ballot(client, db_query, db_session, ballot_factory,
                       voting_phase_factory, proposition_type_factory,
                       logged_in_department_admin):
    data = factory.build(dict, FACTORY_CLASS=ballot_factory)
    department = logged_in_department_admin.managed_departments[0]
    voting_phase = voting_phase_factory(department=department)
    proposition_type = proposition_type_factory()
    area = department.areas[0]
    res = client.get('/b/+new')
    form = assert_deform(res)
    fill_form(form,
              data,
              enum_field_names=['voting_type'],
              skip_field_names=['proposition_type', 'area'])
    form['voting_id'] = voting_phase.id
    form['area_id'] = area.id
    form['proposition_type_id'] = proposition_type.id

    with assert_difference(db_query(Ballot).count, 1):
        form.submit(status=302)