Beispiel #1
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/'
Beispiel #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/'
Beispiel #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]
Beispiel #4
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']
Beispiel #5
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']
Beispiel #6
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]
Beispiel #7
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]
Beispiel #8
0
def test_organisation_change_email(app):
    factories.CampaignFactory()
    organisation = factories.OrganisationFactory()

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

    # Change unconfirmed email
    form = resp.forms['organisation_profile_form']
    form['email'] = '*****@*****.**'
    resp = form.submit('action', value='update_profile')
    assert resp.status_int == 200
    assert errors(resp) == {
        'email': [
            'Patikrinkite savo el. paštą ir patvirtinkite šį el. pašto adresą, tada galėsite jį naudoti.',
        ]
    }
    assert len(mail.outbox) == 1

    # Confirm unconfirmed 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 == '/volunteers/'

    # Change to confirmed email
    resp = app.get('/organisation/profile/', user=organisation.user.username)
    form = resp.forms['organisation_profile_form']
    form['email'] = '*****@*****.**'
    resp = form.submit('action', value='update_profile')
    assert resp.status_int == 302, errors(resp)
    assert len(mail.outbox) == 1

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

    # Check if for was saved
    organisation = Organisation.objects.get(pk=organisation.pk)
    assert organisation.user.email == '*****@*****.**'
Beispiel #9
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]
Beispiel #10
0
def test_organisation_change_email(app):
    factories.CampaignFactory()
    organisation = factories.OrganisationFactory()

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

    # Change unconfirmed email
    form = resp.forms['organisation_profile_form']
    form['email'] = '*****@*****.**'
    resp = form.submit('action', value='update_profile')
    assert resp.status_int == 200
    assert errors(resp) == {'email': [
        'Patikrinkite savo el. paštą ir patvirtinkite šį el. pašto adresą, tada galėsite jį naudoti.',
    ]}
    assert len(mail.outbox) == 1

    # Confirm unconfirmed 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 == '/volunteers/'

    # Change to confirmed email
    resp = app.get('/organisation/profile/', user=organisation.user.username)
    form = resp.forms['organisation_profile_form']
    form['email'] = '*****@*****.**'
    resp = form.submit('action', value='update_profile')
    assert resp.status_int == 302, errors(resp)
    assert len(mail.outbox) == 1

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

    # Check if for was saved
    organisation = Organisation.objects.get(pk=organisation.pk)
    assert organisation.user.email == '*****@*****.**'
Beispiel #11
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']
Beispiel #12
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']
Beispiel #13
0
def test_organisation_change_password(app):
    organisation = factories.OrganisationFactory()
    organisation.user.set_password('senas')
    organisation.user.save()

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

    # Change unconfirmed email
    form = resp.forms['change_password_form']
    form['oldpassword'] = '******'
    form['password1'] = 'naujas'
    form['password2'] = 'naujas'
    resp = form.submit('action', value='change_password')
    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
    organisation = Organisation.objects.get(pk=organisation.pk)
    assert organisation.user.check_password('naujas')
Beispiel #14
0
def test_organisation_change_password(app):
    organisation = factories.OrganisationFactory()
    organisation.user.set_password('senas')
    organisation.user.save()

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

    # Change unconfirmed email
    form = resp.forms['change_password_form']
    form['oldpassword'] = '******'
    form['password1'] = 'naujas'
    form['password2'] = 'naujas'
    resp = form.submit('action', value='change_password')
    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
    organisation = Organisation.objects.get(pk=organisation.pk)
    assert organisation.user.check_password('naujas')