mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-05 06:29:23 +02:00
More factories
This commit is contained in:
parent
feab0f98ba
commit
87daa81762
2 changed files with 65 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
import factory
|
||||
import requests
|
||||
import requests_http_signature
|
||||
import uuid
|
||||
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
|
@ -52,6 +53,21 @@ class SignedRequestFactory(factory.Factory):
|
|||
self.headers.update(default_headers)
|
||||
|
||||
|
||||
@registry.register(name='federation.Link')
|
||||
class LinkFactory(factory.Factory):
|
||||
type = 'Link'
|
||||
href = factory.Faker('url')
|
||||
mediaType = 'text/html'
|
||||
|
||||
class Meta:
|
||||
model = dict
|
||||
|
||||
class Params:
|
||||
audio = factory.Trait(
|
||||
mediaType=factory.Iterator(['audio/mp3', 'audio/ogg'])
|
||||
)
|
||||
|
||||
|
||||
@registry.register
|
||||
class ActorFactory(factory.DjangoModelFactory):
|
||||
public_key = None
|
||||
|
@ -135,3 +151,34 @@ class ActivityFactory(factory.Factory):
|
|||
|
||||
class Meta:
|
||||
model = dict
|
||||
|
||||
|
||||
@registry.register(name='federation.AudioMetadata')
|
||||
class AudioMetadataFactory(factory.Factory):
|
||||
recording = factory.LazyAttribute(
|
||||
lambda o: 'https://musicbrainz.org/recording/{}'.format(uuid.uuid4())
|
||||
)
|
||||
artist = factory.LazyAttribute(
|
||||
lambda o: 'https://musicbrainz.org/artist/{}'.format(uuid.uuid4())
|
||||
)
|
||||
release = factory.LazyAttribute(
|
||||
lambda o: 'https://musicbrainz.org/release/{}'.format(uuid.uuid4())
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = dict
|
||||
|
||||
|
||||
@registry.register(name='federation.Audio')
|
||||
class AudioFactory(factory.Factory):
|
||||
type = 'Audio'
|
||||
id = factory.Faker('url')
|
||||
published = factory.LazyFunction(
|
||||
lambda: timezone.now().isoformat()
|
||||
)
|
||||
actor = factory.Faker('url')
|
||||
url = factory.SubFactory(LinkFactory, audio=True)
|
||||
metadata = factory.SubFactory(AudioMetadataFactory)
|
||||
|
||||
class Meta:
|
||||
model = dict
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue