Esempio n. 1
0
def test_detail_draft_project(client, project, user):
    project_url = reverse('project-detail', args=[project.slug])
    response = client.get(project_url)
    assert response.status_code == 302
    assert redirect_target(response) == 'account_login'

    client.login(username=user.email, password='******')
    response = client.get(project_url)
    assert response.status_code == 403
    assert (
        'euth_projects/project_membership_request.html'
        not in templates_used(response)
    )

    project.participants.add(user)
    response = client.get(project_url)
    assert response.status_code == 403
    assert (
        'euth_projects/project_membership_request.html'
        not in templates_used(response)
    )

    project.organisation.initiators.add(user)
    response = client.get(project_url)
    assert response.status_code == 200
    assert response.context_data['view'].project == project
Esempio n. 2
0
def test_detail_draft_project(client, project, user):
    project_url = reverse('project-detail', args=[project.slug])
    response = client.get(project_url)
    assert response.status_code == 302
    assert redirect_target(response) == 'account_login'

    client.login(username=user.email, password='******')
    response = client.get(project_url)
    assert response.status_code == 403
    assert (
        'euth_projects/project_membership_request.html'
        not in templates_used(response)
    )

    project.participants.add(user)
    response = client.get(project_url)
    assert response.status_code == 403
    assert (
        'euth_projects/project_membership_request.html'
        not in templates_used(response)
    )

    project.organisation.initiators.add(user)
    response = client.get(project_url)
    assert response.status_code == 200
    assert response.context_data['view'].project == project
Esempio n. 3
0
def test_view_invite(client, invite, user):
    url = reverse('membership-invite-detail',
                  kwargs={'invite_token': invite.token})
    response = client.get(url)
    assert response.status_code == 200
    assert (
        'euth_projects/includes/project_hero_unit.html'
        in templates_used(response)
    )
    assert 'euth_memberships/invite_detail.html' in templates_used(response)

    client.login(username=user.email, password='******')
    response = client.get(url)
    assert redirect_target(response) == 'membership-invite-update'
def test_accept_invite(client, invite, user):
    url = reverse('membership-invite-accept',
                  kwargs={'invite_token': invite.token})
    response = client.get(url)
    assert redirect_target(response) == 'account_login'

    client.login(username=user.email, password='******')
    response = client.get(url)
    assert response.status_code == 200
    assert (
        'euth_projects/includes/project_hero_unit.html'
        in templates_used(response)
    )
    assert 'euth_memberships/invite_form.html' in templates_used(response)

    response = client.post(url, data={'accept': ''})
    assert redirect_target(response) == 'project-detail'
    assert user in invite.project.participants.all()
Esempio n. 5
0
def test_accept_invite(client, invite, user):
    url = reverse('membership-invite-update',
                  kwargs={'invite_token': invite.token})
    response = client.get(url)
    assert redirect_target(response) == 'account_login'

    client.login(username=user.email, password='******')
    response = client.get(url)
    assert response.status_code == 200
    assert (
        'euth_projects/includes/project_hero_unit.html'
        in templates_used(response)
    )
    assert 'euth_memberships/invite_form.html' in templates_used(response)

    response = client.post(url, data={'accept': ''})
    assert redirect_target(response) == 'project-detail'
    assert user in invite.project.participants.all()
Esempio n. 6
0
def _verify_valid_response(response):
    """ verifies a response of a request that is considered valid """
    assert response.status_code == 200
    assert 'euth_blueprints/result.html' in templates_used(response)
    assert 'form' not in response.context_data
    assert len(response.context_data['blueprints']) > 0

    for b in response.context_data['blueprints']:
        # verify that for every blueprint a name, the blueprint and a
        # time is given
        assert len(b) == 3
Esempio n. 7
0
def test_form_view(client, organisation):
    user = organisation.initiators.first()
    client.login(username=user.email, password='******')

    url = reverse('blueprints-form', kwargs={
        'organisation_slug': organisation.slug
    })
    response = client.get(url)

    assert response.status_code == 200
    assert 'euth_blueprints/form.html' in templates_used(response)
    assert len(response.context_data['form'].errors) == 0
def test_create_request(client, project, user):
    url = reverse('memberships-request', kwargs={'project_slug': project.slug})
    response = client.get(url)
    assert redirect_target(response) == 'account_login'

    client.login(username=user.email, password='******')
    response = client.get(url)
    assert response.status_code == 200
    assert (
        'euth_projects/includes/project_hero_unit.html'
        in templates_used(response)
    )
    assert 'euth_memberships/request_detail.html' in templates_used(response)

    response = client.post(url, data={})
    assert redirect_target(response) == 'memberships-request'
    assert bool(models.Request.objects.filter(creator=user, project=project))
    assert mail.outbox[0].to == [project.moderators.first().email]

    project.participants.add(user)
    response = client.get(url)
    assert redirect_target(response) == 'project-detail'
Esempio n. 9
0
def test_create_request(client, project, user):
    url = reverse('memberships-request', kwargs={'project_slug': project.slug})
    response = client.get(url)
    assert redirect_target(response) == 'account_login'

    client.login(username=user.email, password='******')
    response = client.get(url)
    assert response.status_code == 200
    assert (
        'euth_projects/includes/project_hero_unit.html'
        in templates_used(response)
    )
    assert 'euth_memberships/request_detail.html' in templates_used(response)

    response = client.post(url, data={})
    assert redirect_target(response) == 'memberships-request'
    assert bool(models.Request.objects.filter(creator=user, project=project))
    assert mail.outbox[0].to == [project.moderators.first().email]

    project.participants.add(user)
    response = client.get(url)
    assert redirect_target(response) == 'project-detail'
Esempio n. 10
0
def test_form_error_2(client, organisation):
    user = organisation.initiators.first()
    client.login(username=user.email, password='******')

    url = reverse('blueprints-form', kwargs={
        'organisation_slug': organisation.slug
    })
    data = {
        'aim': 'collect_ideas',
        'result': '3',
        'motivation': '500000',
        'experience': '4',
        'participants': '1',
        'scope': '-1',
        'duration': '1',
        'accessibility': '2'
    }
    response = client.post(url, data)

    assert response.status_code == 200
    assert 'euth_blueprints/form.html' in templates_used(response)
    assert len(response.context_data['form'].errors) == 2