def test_get_specified_position(testing_server):
    session = election_subtests.create_elections_admin()
    position_data = position_subtests.create_positions(session)
    for key, position in position_data.items():
        resp = position_requests.get_specified_position(key)
        assert (resp.status_code == 200)
        position_subtests.assert_position_data(json.loads(resp.text), position)
Beispiel #2
0
def test_put_specified_candidate(testing_server):
    session = election_subtests.create_elections_admin()
    election_id, position_ids = candidate_utils.create_default_candidate_params(
        session)
    candidate_data = candidate_utils.create_candidates(session, election_id,
                                                       position_ids)

    for candidate_id, candidate in candidate_data.items():
        updated_candidate_data = {
            'id':
            candidate_id,
            'election':
            election_id,
            'position':
            position_ids[1]
            if candidate['position'] == position_ids[0] else position_ids[0],
            'username':
            candidate['username'] + '_updated',
            'display_name':
            candidate['display_name'] + '_updated'
        }
        resp = candidate_requests.put_specified_candidate(
            session, election_id, candidate_id, updated_candidate_data)
        assert (resp.status_code == 200)
        candidate_utils.assert_candidate_data(json.loads(resp.text),
                                              updated_candidate_data)
def test_get_position(testing_server):
    session = election_subtests.create_elections_admin()
    position_data = position_subtests.create_positions(session)

    resp = position_requests.get_position()
    assert (resp.status_code == 200)
    resp_data = json.loads(resp.text)['positions']
    for data in resp_data:
        position_subtests.assert_position_data(data, position_data[data['id']])
def test_post_vote(testing_server):
    admin_session = election_subtests.create_elections_admin()
    election_id = election_subtests.assert_post_dynamic_election(
        admin_session)['id']
    position_resp = position_requests.post_position(
        admin_session, POSITION_DATA['position'],
        POSITION_DATA['election_type'], POSITION_DATA['active'],
        POSITION_DATA['order'])
    position_id = json.loads(position_resp.text)['id']
    vote_subtests.create_votes(admin_session, election_id, position_id)
Beispiel #5
0
def test_get_specified_candidate(testing_server):
    session = election_subtests.create_elections_admin()
    election_id, position_ids = candidate_utils.create_default_candidate_params(
        session)
    candidate_data = candidate_utils.create_candidates(session, election_id,
                                                       position_ids)

    for candidate_id, candidate in candidate_data.items():
        resp = candidate_requests.get_specified_candidate(
            election_id, candidate_id)
        assert (resp.status_code == 200)
        resp_data = json.loads(resp.text)
        candidate_utils.assert_candidate_data(resp_data, candidate)
Beispiel #6
0
def test_get_candidate(testing_server):
    session = election_subtests.create_elections_admin()
    election_id, position_ids = candidate_utils.create_default_candidate_params(
        session)
    candidate_data = candidate_utils.create_candidates(session, election_id,
                                                       position_ids)

    resp = candidate_requests.get_candidate(election_id)
    assert (resp.status_code == 200)
    resp_data = json.loads(resp.text)['candidates']
    for candidate in resp_data:
        assert (candidate['id'] in candidate_data)
        candidate_utils.assert_candidate_data(candidate,
                                              candidate_data[candidate['id']])
def test_put_specified_position(testing_server):
    session = election_subtests.create_elections_admin()
    position_data = position_subtests.create_positions(session)
    for key, value in position_data.items():
        updated_position_data = {
            'id': key,
            'position': value['position'] + '_updated',
            'election_type': 'senate' if value['election_type'] == 'aswwu' else 'aswwu',
            'active': value['active'] == 'True',
            'order': int(value['order']) + 1
        }
        resp = position_requests.put_specified_position(session, position_id=key,
                                                        position=updated_position_data['position'],
                                                        election_type=updated_position_data['election_type'],
                                                        active=updated_position_data['active'],
                                                        order=updated_position_data['order'])
        assert(resp.status_code == 200)
        position_subtests.assert_position_data(json.loads(resp.text), updated_position_data)
def test_get_vote(testing_server):
    admin_session = election_subtests.create_elections_admin()
    election_id = election_subtests.assert_post_dynamic_election(
        admin_session)['id']
    position_resp = position_requests.post_position(
        admin_session, POSITION_DATA['position'],
        POSITION_DATA['election_type'], POSITION_DATA['active'],
        POSITION_DATA['order'])
    position_id = json.loads(position_resp.text)['id']
    vote_data = vote_subtests.create_votes(admin_session, election_id,
                                           position_id)
    users = utils.load_csv(paths.USERS_PATH)

    for count, user in enumerate(users):
        user_session = auth_subtests.assert_verify_login(user)[1]
        resp = vote_requests.get_vote(user_session, position_id,
                                      user['username'])
        assert (resp.status_code == 200)
        resp_text = json.loads(resp.text)['votes']
        for vote in resp_text:
            vote_subtests.assert_vote_data(vote, vote_data[user['username']])
def test_put_specified_election(testing_server):
    session = election_subtests.create_elections_admin()
    election_data = election_subtests.create_elections(session)
    for election_id, election in election_data.items():
        updated_election_data = {
            'election_type':
            'aswwu' if election['election_type'] == 'senate' else 'senate',
            'name': election['name'] + '_updated',
            'max_votes': election['max_votes'] + 1,
            'start': election_subtests.add_hour_dt(election['start']),
            'end': election_subtests.add_hour_dt(election['end']),
            'show_results':
            election_subtests.add_hour_dt(election['show_results'])
        }
        resp = election_requests.put_specified_election(
            session, election_id, updated_election_data['election_type'],
            updated_election_data['name'], updated_election_data['max_votes'],
            updated_election_data['start'], updated_election_data['end'],
            updated_election_data['show_results'])
        assert (resp.status_code == 200)
        election_subtests.assert_election_data(json.loads(resp.text),
                                               updated_election_data)
Beispiel #10
0
def test_post_candidate(testing_server):
    session = election_subtests.create_elections_admin()
    election_id, position_ids = candidate_utils.create_default_candidate_params(
        session)
    candidate_utils.create_candidates(session, election_id, position_ids)
def test_post_position(testing_server):
    session = election_subtests.create_elections_admin()
    position_subtests.create_positions(session)
def test_get_current(testing_server):
    session = election_subtests.create_elections_admin()
    election_subtests.assert_post_dynamic_election(session)