Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Walko
funkwhale
Commits
87daa817
Verified
Commit
87daa817
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
More factories
parent
feab0f98
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/funkwhale_api/federation/factories.py
+47
-0
47 additions, 0 deletions
api/funkwhale_api/federation/factories.py
api/funkwhale_api/music/factories.py
+18
-0
18 additions, 0 deletions
api/funkwhale_api/music/factories.py
with
65 additions
and
0 deletions
api/funkwhale_api/federation/factories.py
+
47
−
0
View file @
87daa817
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
This diff is collapsed.
Click to expand it.
api/funkwhale_api/music/factories.py
+
18
−
0
View file @
87daa817
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment