Skip to content

Commit

Permalink
tests/dashboard: test module create
Browse files Browse the repository at this point in the history
  • Loading branch information
rine authored and fuzzylogic2000 committed Sep 9, 2022
1 parent 9259391 commit c60ac67
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/dashboard/test_dashboard_views_module_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import pytest
from django.urls import reverse
from rest_framework import status

from adhocracy4.modules.models import Module


@pytest.mark.django_db
def test_module_create(client, project, user):
organisation = project.organisation
organisation.initiators.add(user)

module_create_url = reverse(
'a4dashboard:module-create',
kwargs={
'project_slug': project.slug,
'blueprint_slug': 'idea-collection'
}
)

client.login(username=user, password='password')
response = client.post(module_create_url)
assert response.status_code == status.HTTP_302_FOUND
assert Module.objects.all().count() == 1
module = Module.objects.first()
assert response.url == reverse(
'a4dashboard:dashboard-module_basic-edit',
kwargs={'module_slug': module.slug}
)
assert module.project == project
assert module.weight == 1
assert module.blueprint_type == 'IC'

client.post(module_create_url)
assert Module.objects.all().count() == 2
module = Module.objects.last()
assert module.weight == 2

0 comments on commit c60ac67

Please sign in to comment.