merge-requests/154/head
Eliot Berriot 2018-04-05 23:27:19 +02:00
rodzic feab0f98ba
commit 87daa81762
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
2 zmienionych plików z 65 dodań i 0 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -2,6 +2,10 @@ import factory
import os
from funkwhale_api.factories import registry, ManyToManyFromList
from funkwhale_api.federation.factories import (
AudioMetadataFactory,
ActorFactory,
)
from funkwhale_api.users.factories import UserFactory
SAMPLES_PATH = os.path.join(
@ -61,6 +65,13 @@ class ImportBatchFactory(factory.django.DjangoModelFactory):
class Meta:
model = 'music.ImportBatch'
class Params:
federation = factory.Trait(
submitted_by=None,
federation_actor=factory.SubFactory(ActorFactory),
source='federation',
)
@registry.register
class ImportJobFactory(factory.django.DjangoModelFactory):
@ -71,6 +82,13 @@ class ImportJobFactory(factory.django.DjangoModelFactory):
class Meta:
model = 'music.ImportJob'
class Params:
federation = factory.Trait(
batch=factory.SubFactory(ImportBatchFactory, federation=True),
federation_source=factory.Faker('url'),
metadata=factory.SubFactory(AudioMetadataFactory),
)
@registry.register(name='music.FileImportJob')
class FileImportJobFactory(ImportJobFactory):