Ejemplo n.º 1
0
def test_api_not_open_presenters(client, monkeypatch):
    assert client is not None
    monkeypatch.setitem(app.config, 'API_ACCESS', False)
    get_and_check_content(client, '/presenters', 302, (
        'Redirect',
        '<a href="/">',
    ))
Ejemplo n.º 2
0
def test_ensure_registration_and_login(client, registrant, monkeypatch):
    monkeypatch.setitem(app.config, 'CALL_OPEN', True)
    user = User.query.filter_by(email=registrant['email']).all()
    assert len(user) == 0
    post_and_check_content(
        client,
        '/register',
        json.dumps(registrant),
        'application/json',
        includes=('register_success', ),
        excludes=(),
    )
    user = User.query.filter_by(email=registrant['email']).all()
    assert len(user) == 1
    assert user[0].passphrase == hash_passphrase(registrant['passphrase'])
    post_and_check_content(
        client,
        '/login',
        json.dumps({
            'email': registrant['email'],
            'passphrase': registrant['passphrase']
        }),
        'application/json',
        includes=('login_success', ),
        excludes=(),
    )
    get_and_check_content(
        client,
        '/login_success',
        includes=(' – Login Successful', 'Login successful'),
        excludes=(),
    )
Ejemplo n.º 3
0
def test_logout_not_in_open_state_cases_redirect(client):
    get_and_check_content(
        client,
        '/logout',
        code=302,
        includes=('Redirecting', '<a href="/">'),
    )
Ejemplo n.º 4
0
def test_attempt_to_get_login_page_outside_open_period_causes_redirect(client):
    get_and_check_content(
        client,
        '/login',
        code=302,
        includes=('Redirect', '<a href="/">'),
    )
Ejemplo n.º 5
0
def test_logged_in_user_cannot_submit_multipresenter_multilead_proposal(
        client, registrant, proposal_multiple_presenters_and_leads,
        monkeypatch):
    test_ensure_registration_and_login(client, registrant, monkeypatch)
    presenters = proposal_multiple_presenters_and_leads['presenters']
    post_and_check_content(
        client,
        '/submit',
        json.dumps(proposal_multiple_presenters_and_leads),
        'application/json',
        code=400,
        includes=("['{}', '{}'] marked as lead presenters".format(
            presenters[0]['email'], presenters[1]['email']), ),
        excludes=(login_menu_item, register_menu_item),
    )
    get_and_check_content(
        client,
        '/register_success',
        includes=(' – Registration Successful',
                  'You have successfully registered'),
        excludes=(),
    )
    user = User.query.filter_by(email=registrant['email']).all()
    assert len(user) == 1
    user = user[0]
    assert user is not None
    assert len(user.proposals) == 0
Ejemplo n.º 6
0
def test_proposal_update_success_not_available_when_not_open(client):
    get_and_check_content(
        client,
        '/proposal_update_success',
        code=302,
        includes=('Redirecting', '<a href="/">'),
    )
Ejemplo n.º 7
0
def test_api_open_index(client, monkeypatch):
    assert client is not None
    monkeypatch.setitem(app.config, 'API_ACCESS', True)
    get_and_check_content(client, '/', 200, (
        'ACCU',
        'API Access',
    ))
def test_registered_reviewer_can_login(client, registrant, monkeypatch):
    monkeypatch.setitem(app.config, 'REVIEWING_ALLOWED', True)
    user = User.query.filter_by(email=registrant['email']).all()
    assert len(user) == 0
    add_new_user(registrant)
    user = User.query.filter_by(email=registrant['email']).all()
    assert len(user) == 1
    user = user[0]
    assert user.email == registrant['email']
    assert user.passphrase == hash_passphrase(registrant['passphrase'])
    assert user.role == Role.user
    user.role = Role.reviewer
    db.session.commit()
    post_and_check_content(
        client,
        '/login',
        json.dumps({
            'email': registrant['email'],
            'passphrase': registrant['passphrase']
        }),
        'application/json',
        includes=('login_success', ),
        excludes=(),
    )
    get_and_check_content(
        client,
        '/login_success',
        includes=(' – Login Successful', 'Login successful', logout_menu_item,
                  registration_update_menu_item),
        excludes=(login_menu_item, my_proposals_menu_item, register_menu_item,
                  submit_menu_item),
    )
Ejemplo n.º 9
0
def test_user_can_register(client, registrant, monkeypatch):
    monkeypatch.setitem(app.config, 'CALL_OPEN', True)
    user = User.query.filter_by(email=registrant['email']).all()
    assert len(user) == 0
    post_and_check_content(
        client,
        '/register',
        json.dumps(registrant),
        'application/json',
        includes=('register_success', ),
        excludes=(
            login_menu_item,
            register_menu_item,
        ),
    )
    get_and_check_content(
        client,
        '/register_success',
        includes=(' – Registration Successful',
                  'You have successfully registered', login_menu_item,
                  register_menu_item),
        excludes=(logout_menu_item, my_proposals_menu_item,
                  registration_update_menu_item, submit_menu_item),
    )
    user = User.query.filter_by(email=registrant['email']).all()
    assert len(user) == 1
    assert user[0].email == registrant['email']
    assert user[0].passphrase == hash_passphrase(registrant['passphrase'])
Ejemplo n.º 10
0
def test_attempt_get_login_success_out_of_open_causes_redirect(client):
    get_and_check_content(
        client,
        '/login_success',
        code=302,
        includes=('Redirecting', '<a href="/">'),
    )
Ejemplo n.º 11
0
def test_proposals_update_not_available_when_not_open(client):
    get_and_check_content(
        client,
        '/proposal_update/0',
        code=302,
        includes=('Redirect', '<a href="/">'),
        excludes=(login_menu_item, register_menu_item),
    )
Ejemplo n.º 12
0
def test_submit_not_available_when_not_open(client):
    get_and_check_content(
        client,
        '/submit',
        code=302,
        includes=('Redirect', '<a href="/">'),
        excludes=(login_menu_item, register_menu_item),
    )
def test_logged_in_user_can_logout_with_get(client, registrant, monkeypatch):
    test_successful_login(client, registrant, monkeypatch)
    get_and_check_content(
        client,
        '/logout',
        code=302,
        includes=('Redirecting', '<a href="/">'),
    )
Ejemplo n.º 14
0
def test_registration_page_has_some_countries(client, monkeypatch):
    monkeypatch.setitem(app.config, 'CALL_OPEN', True)
    get_and_check_content(
        client,
        '/register',
        includes=('Register', 'United Kingdom'),
        excludes=(register_menu_item, 'GBR'),
    )
def test_new_registerations_not_allowed(client, monkeypatch):
    monkeypatch.setitem(app.config, 'REVIEWING_ALLOWED', True)
    get_and_check_content(
        client,
        '/register',
        code=302,
        includes=('Redirect', '<a href="/">'),
    )
Ejemplo n.º 16
0
def test_logout_without_login_is_noop(client, monkeypatch):
    monkeypatch.setitem(app.config, 'CALL_OPEN', True)
    get_and_check_content(
        client,
        '/logout',
        code=302,
        includes=('Redirecting', '<a href="/">'),
    )
Ejemplo n.º 17
0
def test_attempt_to_get_login_success_not_after_login_causes_redirect(
        client, registrant, monkeypatch):
    test_user_can_register(client, registrant, monkeypatch)
    get_and_check_content(
        client,
        '/login_success',
        code=302,
        includes=('Redirecting', '<a href="/">'),
    )
Ejemplo n.º 18
0
def test_logged_in_user_can_get_registration_update_page(
        client, registrant, monkeypatch):
    test_successful_login(client, registrant, monkeypatch)
    get_and_check_content(
        client,
        '/registration_update',
        includes=(' – Registration Details Updating', ),
        excludes=(),
    )
def test_logged_in_reviewer_can_get_review_list(client, registrant,
                                                monkeypatch):
    test_registered_reviewer_can_login(client, registrant, monkeypatch)
    get_and_check_content(
        client,
        '/review_list',
        includes=(' – List of Proposals', ),
        excludes=(),
    )
Ejemplo n.º 20
0
def test_not_logged_in_user_cannot_get_submission_page(client, monkeypatch):
    monkeypatch.setitem(app.config, 'CALL_OPEN', True)
    get_and_check_content(
        client,
        '/submit',
        includes=('Submit',
                  'You must be registered and logged in to submit a proposal.',
                  login_menu_item, register_menu_item),
    )
Ejemplo n.º 21
0
def test_attempt_get_registration_update_success_out_of_open_causes_redirect(
        client):
    get_and_check_content(
        client,
        '/registration_update_success',
        code=302,
        includes=('Redirecting', '<a href="/">'),
        excludes=(),
    )
Ejemplo n.º 22
0
def test_logged_in_user_can_get_submission_page(client, registrant,
                                                monkeypatch):
    test_ensure_registration_and_login(client, registrant, monkeypatch)
    get_and_check_content(
        client,
        '/submit',
        includes=('Submit', ),
        excludes=(login_menu_item, register_menu_item),
    )
Ejemplo n.º 23
0
def test_attempt_to_get_registration_update_success_not_after_registration_update_causes_redirect(
        client, registrant, monkeypatch):
    test_successful_user_registration(client, registrant, monkeypatch)
    get_and_check_content(
        client,
        '/registration_update_success',
        code=302,
        includes=('Redirecting', '<a href="/">'),
        excludes=(),
    )
def test_user_not_a_reviewer_can_register_and_login_but_not_see_review_proposal_page(
        client, registrant, monkeypatch):
    test_user_not_a_reviewer_already_registered_can_login(
        client, registrant, monkeypatch)
    get_and_check_content(
        client,
        '/review_proposal/1',
        code=302,
        includes=('Redirect', '<a href="/">'),
    )
Ejemplo n.º 25
0
def test_get_registration_update_success_after_correct_registration_update(
        client, registrant, monkeypatch):
    test_registration_update(client, registrant, monkeypatch)
    get_and_check_content(
        client,
        '/registration_update_success',
        includes=(' – Registration Update Successful',
                  'Your registration details were successfully updated.'),
        excludes=(),
    )
def test_attempt_to_get_login_page_outside_open_period_causes_redirect(
        client, monkeypatch):
    monkeypatch.setitem(app.config, 'CALL_OPEN', False)
    monkeypatch.setitem(app.config, 'REVIEWING_ALLOWED', False)
    monkeypatch.setitem(app.config, 'MAINTENANCE', False)
    get_and_check_content(
        client,
        '/login',
        code=302,
        includes=('Redirect', '<a href="/">'),
    )
Ejemplo n.º 27
0
def test_logged_in_submit_proposal_then_update_it(client, registrant,
                                                  proposal_single_presenter,
                                                  monkeypatch):
    test_logged_in_user_can_submit_a_single_presenter_proposal(
        client, registrant, proposal_single_presenter, monkeypatch)
    get_and_check_content(
        client,
        '/proposal_update/1',
        includes=(proposal_single_presenter['title'],
                  proposal_single_presenter['presenters'][0]['email']),
        excludes=(),
    )
def test_logged_in_reviewer_can_get_review_proposal_for_not_own_entries(
        client, registrant, monkeypatch):
    add_new_user(new_user)
    add_a_proposal_as_user(new_user['email'], get_proposal_single_presenter())
    add_a_proposal_as_user(new_user['email'],
                           get_proposal_multiple_presenters_single_lead())
    test_registered_reviewer_can_login(client, registrant, monkeypatch)
    get_and_check_content(
        client,
        '/review_proposal/1',
        includes=(' – Proposal to Review', ),
        excludes=(),
    )
Ejemplo n.º 29
0
def test_logged_in_user_can_update_a_previously_submitted_multiple_presenter_proposal(
        client, registrant, proposal_multiple_presenters_single_lead,
        monkeypatch):
    test_logged_in_user_can_submit_multipresenter_single_lead_proposal(
        client, registrant, proposal_multiple_presenters_single_lead,
        monkeypatch)
    alternate_title = 'This is an alternate title'
    alternate_email = '[email protected]'
    monkeypatch.setitem(proposal_multiple_presenters_single_lead, 'title',
                        alternate_title)
    monkeypatch.setitem(
        proposal_multiple_presenters_single_lead['presenters'][1], 'email',
        alternate_email)
    post_and_check_content(
        client,
        '/proposal_update/1',
        json.dumps(proposal_multiple_presenters_single_lead),
        'application/json',
        includes=('proposal_update_success', ),
        excludes=(login_menu_item, register_menu_item),
    )
    get_and_check_content(
        client,
        '/proposal_update_success',
        includes=('Update Successful',
                  'Thank you, you have successfully updated'),
        excludes=(login_menu_item, register_menu_item),
    )
    user = User.query.filter_by(email=registrant['email']).all()
    assert len(user) == 1
    user = user[0]
    assert user is not None
    assert len(user.proposals) == 1
    proposal = user.proposals[0]
    assert proposal is not None
    assert proposal.title == alternate_title
    assert proposal.session_type == SessionType.workshop
    presenters = proposal.presenters
    proposal_presenters = proposal.proposal_presenters
    assert len(presenters) == 2
    assert len(proposal_presenters) == 2
    presenter = proposal.presenters[1]
    assert presenter.email == alternate_email
    original_presenters = proposal_multiple_presenters_single_lead[
        'presenters']
    if proposal_presenters[0].is_lead:
        assert presenters[0].email == original_presenters[0]['email']
        assert presenters[1].email == original_presenters[1]['email']
    else:
        assert presenters[0].email == original_presenters[1]['email']
        assert presenters[1].email == original_presenters[0]['email']
Ejemplo n.º 30
0
def test_logged_in_get_my_proposals_page(client, registrant,
                                         proposal_single_presenter,
                                         monkeypatch):
    test_logged_in_user_can_submit_a_single_presenter_proposal(
        client, registrant, proposal_single_presenter, monkeypatch)
    get_and_check_content(
        client,
        '/my_proposals',
        includes=(
            'My Proposals',
            'The following are your current proposals.',
            '<li class="proposal-list"><a href="/proposal_update/1"> A single presenter proposal </a></li>',
            registration_update_menu_item,
        ),
        excludes=(login_menu_item, register_menu_item))