Ejemplo n.º 1
0
def test_volunteer_profile(app):
    volunteer = factories.VolunteerFactory()
    naujamiestis = factories.PlaceFactory(wikipedia_title='Naujamiestis')

    resp = app.get('/volunteer/profile/', user=volunteer.user.username)
    assert resp.status_int == 200

    # Fill and submit profile form
    form = resp.forms['volunteer_profile_form']
    form['first_name'] = 'New first'
    form['last_name'] = 'New last'
    form['places'].force_value([naujamiestis.pk])
    resp = form.submit('action', value='update_profile')
    assert resp.status_int == 302, errors(resp)
    assert len(mail.outbox) == 0

    # Check redirect
    resp = resp.follow()
    assert resp.request.path == '/volunteer/profile/'

    # Check if for was saved
    volunteer = Volunteer.objects.get(pk=volunteer.pk)
    assert volunteer.user.first_name == 'New first'
    assert volunteer.user.last_name == 'New last'
    assert [x.wikipedia_title
            for x in volunteer.places.all()] == ['Naujamiestis']
Ejemplo n.º 2
0
def test_volunteer(app):
    place = factories.PlaceFactory()
    shifts = factories.ShiftFactory.create_batch(len(factories.shifts))

    # Open login form
    resp = app.get('/')

    # Click on 'Savanoriams'
    resp = resp.click('Savanoriams')

    # Fill and submit registration form
    form = resp.forms['signup_form']
    form['first_name'] = 'First'
    form['last_name'] = 'Last'
    form['email'] = '*****@*****.**'
    form['password1'] = 'secret'
    form['password2'] = 'secret'
    form['places'].force_value([place.pk])
    form['shift'] = [shifts[0].pk]
    form['agreement'] = True
    resp = form.submit()
    assert resp.status_int == 302, errors(resp)
    assert len(mail.outbox) == 1
    assert mail.outbox[
        0].subject == '[savanoriai.maistobankas.lt] Prašome patvirtinti savo el. pašto adresą'
    assert 'savanorio profilį' in mail.outbox[0].body
    assert 'organizacijos profilį' not in mail.outbox[0].body

    # Check if user was created
    volunteer = Volunteer.objects.get(user__email='*****@*****.**')
    assert volunteer.user.first_name == 'First'
    assert volunteer.user.last_name == 'Last'
    assert [x.wikipedia_title
            for x in volunteer.places.all()] == ['Senamiestis']
    assert [shift.title for shift in volunteer.shift.all()
            ] == ['Pirmadienis (14:45-18:00)']

    # Check redirect
    resp = resp.follow()
    assert resp.request.path == '/accounts/confirm-email/'

    # Confirg email
    confirmation_url = re.search(r'/accounts/confirm-email/[^/]+/',
                                 mail.outbox[0].body).group(0)
    resp = app.get(confirmation_url)
    resp = resp.form.submit()
    resp = resp.follow()
    assert resp.request.path == '/accounts/login/'

    # Login
    form = resp.forms['login']
    form['login'] = '******'
    form['password'] = '******'
    resp = form.submit()
    assert resp.status_int == 302, errors(resp)

    # Check redirect
    resp = resp.follow()
    assert resp.request.path == '/volunteer/profile/'
Ejemplo n.º 3
0
def test_volunteer(app):
    admin = factories.AdminUserFactory()
    place = factories.PlaceFactory()
    shifts = factories.ShiftFactory.create_batch(len(factories.shifts))

    # Create new volunteer
    resp = app.get('/admin/core/volunteer/add/', user=admin.username)
    assert resp.status_int == 200

    form = resp.forms['volunteer_form']
    form['first_name'] = 'First'
    form['last_name'] = 'Last'
    form['email'] = '*****@*****.**'
    form['phone'] = '1111111111'
    form['experience'] = '1'
    form['places'].force_value([place.pk])
    form['shift'] = [shifts[0].pk]
    resp = form.submit('_continue')
    # resp.showbrowser()
    assert resp.status_int == 302, errors(resp)
    assert len(mail.outbox) == 0

    obj = Volunteer.objects.get(user__email='*****@*****.**')
    assert obj.user.first_name == 'First'
    assert obj.phone == '1111111111'
    assert [x.wikipedia_title
            for x in obj.places.all()] == [place.wikipedia_title]

    # Update existing volunteer
    resp = app.get('/admin/core/volunteer/%d/change/' % obj.pk,
                   user=admin.username)
    assert resp.status_int == 200

    form = resp.forms['volunteer_form']
    form['first_name'] = 'Name'
    form['last_name'] = 'Last'
    form['email'] = '*****@*****.**'
    form['phone'] = '2222222222'
    form['places'].force_value([place.pk])
    form['shift'] = [shifts[0].pk]
    resp = form.submit('_continue')
    assert resp.status_int == 302, errors(resp)
    assert len(mail.outbox) == 0

    obj = Volunteer.objects.get(pk=obj.pk)
    assert obj.user.first_name == 'Name'
    assert obj.phone == '2222222222'
    assert [x.wikipedia_title
            for x in obj.places.all()] == [place.wikipedia_title]
Ejemplo n.º 4
0
def test_organisation(app):
    place = factories.PlaceFactory()
    admin = factories.AdminUserFactory()

    # Create new organisation
    resp = app.get('/admin/core/organisation/add/', user=admin.username)
    assert resp.status_int == 200

    form = resp.forms['organisation_form']
    form['first_name'] = 'First'
    form['email'] = '*****@*****.**'
    form['phone'] = '1111111111'
    form['places'].force_value([place.pk])
    resp = form.submit('_continue')
    assert resp.status_int == 302, errors(resp)
    assert len(mail.outbox) == 0

    obj = Organisation.objects.get(user__email='*****@*****.**')
    assert obj.user.first_name == 'First'
    assert obj.phone == '1111111111'
    assert [x.wikipedia_title
            for x in obj.places.all()] == [place.wikipedia_title]

    # Update existing organisation
    resp = app.get('/admin/core/organisation/%d/change/' % obj.pk,
                   user=admin.username)
    assert resp.status_int == 200

    form = resp.forms['organisation_form']
    form['first_name'] = 'Name'
    form['email'] = '*****@*****.**'
    form['phone'] = '2222222222'
    form['places'].force_value([place.pk])
    resp = form.submit('_continue')
    assert resp.status_int == 302, errors(resp)
    assert len(mail.outbox) == 0

    obj = Organisation.objects.get(pk=obj.pk)
    assert obj.user.first_name == 'Name'
    assert obj.phone == '2222222222'
    assert [x.wikipedia_title
            for x in obj.places.all()] == [place.wikipedia_title]
Ejemplo n.º 5
0
def test_organisation_profile(app):
    org = factories.OrganisationFactory()
    naujamiestis = factories.PlaceFactory(wikipedia_title='Naujamiestis')

    resp = app.get('/organisation/profile/', user=org.user.username)
    assert resp.status_int == 200

    # Fill and submit profile form
    form = resp.forms['organisation_profile_form']
    form['first_name'] = 'New name'
    form['places'].force_value([naujamiestis.pk])
    resp = form.submit('action', value='update_profile')
    assert resp.status_int == 302, errors(resp)
    assert len(mail.outbox) == 0

    # Check redirect
    resp = resp.follow()
    assert resp.request.path == '/organisation/profile/'

    # Check if for was saved
    org = Organisation.objects.get(pk=org.pk)
    assert org.user.first_name == 'New name'
    assert [x.wikipedia_title for x in org.places.all()] == ['Naujamiestis']