Skip to content
Snippets Groups Projects
Verified Commit 4f906b36 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

test: fix permissions for note tests

parent ae721780
No related branches found
No related tags found
No related merge requests found
import datetime import datetime
from django.contrib.auth.models import User from django.contrib.auth.models import Permission, User
from django.utils.text import slugify from django.utils.text import slugify
from django.utils.timezone import now from django.utils.timezone import now
from program.models import Note, RRule, Schedule, Show, TimeSlot from program.models import Note, RRule, Schedule, Show, TimeSlot
...@@ -31,6 +31,8 @@ class UserMixin: ...@@ -31,6 +31,8 @@ class UserMixin:
self.user_common = User.objects.create_user( self.user_common = User.objects.create_user(
"herbert", "herbert@aura.radio", password="herbert" "herbert", "herbert@aura.radio", password="herbert"
) )
note_permissions = Permission.objects.filter(content_type__model="note")
self.user_common.user_permissions.add(*note_permissions)
class ShowMixin: class ShowMixin:
...@@ -78,14 +80,12 @@ class NoteMixin: ...@@ -78,14 +80,12 @@ class NoteMixin:
_title = kwargs.get("title", f"a random note #{note_count}") _title = kwargs.get("title", f"a random note #{note_count}")
kwargs["timeslot"] = timeslot kwargs["timeslot"] = timeslot
kwargs["title"] = _title kwargs["title"] = _title
kwargs.setdefault("slug", slugify(_title))
return Note.objects.create(**kwargs) return Note.objects.create(**kwargs)
def _create_random_note_content(self, **kwargs): def _create_random_note_content(self, **kwargs):
note_count = Note.objects.all().count() note_count = Note.objects.all().count()
_title = kwargs.get("title", f"a random note #{note_count}") _title = kwargs.get("title", f"a random note #{note_count}")
kwargs["title"] = _title kwargs["title"] = _title
kwargs.setdefault("slug", slugify(_title))
kwargs.setdefault("content", "some random content") kwargs.setdefault("content", "some random content")
kwargs.setdefault("contributor_ids", []) kwargs.setdefault("contributor_ids", [])
return kwargs return kwargs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment