Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Georg Abenthung
funkwhale
Commits
1a3e7a5e
Commit
1a3e7a5e
authored
Mar 12, 2019
by
gordon
Committed by
Eliot Berriot
Mar 12, 2019
Browse files
Fix Factories for dev data
parent
4a9e7fa7
Changes
2
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/factories.py
View file @
1a3e7a5e
import
uuid
import
factory
import
persisting_theory
from
faker.providers
import
internet
as
internet_provider
class
FactoriesRegistry
(
persisting_theory
.
Registry
):
look_into
=
"factories"
...
...
@@ -39,3 +42,22 @@ class NoUpdateOnCreate:
@
classmethod
def
_after_postgeneration
(
cls
,
instance
,
create
,
results
=
None
):
return
class
FunkwhaleProvider
(
internet_provider
.
Provider
):
"""
Our own faker data generator, since built-in ones are sometimes
not random enough
"""
def
federation_url
(
self
,
prefix
=
""
):
def
path_generator
():
return
"{}/{}"
.
format
(
prefix
,
uuid
.
uuid4
())
domain
=
self
.
domain_name
()
protocol
=
"https"
path
=
path_generator
()
return
"{}://{}/{}"
.
format
(
protocol
,
domain
,
path
)
factory
.
Faker
.
add_provider
(
FunkwhaleProvider
)
changes/changelog.d/factories.bugfix
0 → 100644
View file @
1a3e7a5e
Fixed dev command for fake data creation (!664)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment