SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
SciPost
SciPost
Commits
7a0ee77b
Commit
7a0ee77b
authored
7 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Add Remark factory
parent
fa79c00f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scipost/factories.py
+27
-13
27 additions, 13 deletions
scipost/factories.py
with
27 additions
and
13 deletions
scipost/factories.py
+
27
−
13
View file @
7a0ee77b
...
...
@@ -4,16 +4,16 @@ import random
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth.models
import
Group
from
django_countries.data
import
COUNTRIES
from
submissions.models
import
Submission
from
.models
import
Contributor
,
EditorialCollege
,
EditorialCollegeFellowship
from
.models
import
Contributor
,
EditorialCollege
,
EditorialCollegeFellowship
,
Remark
from
.constants
import
TITLE_CHOICES
from
django_countries.data
import
COUNTRIES
from
faker
import
Faker
class
ContributorFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
Contributor
class
ContributorFactory
(
factory
.
django
.
DjangoModelFactory
):
title
=
random
.
choice
(
list
(
dict
(
TITLE_CHOICES
).
keys
()))
user
=
factory
.
SubFactory
(
'
scipost.factories.UserFactory
'
,
contributor
=
None
)
status
=
1
# normal user
...
...
@@ -22,6 +22,10 @@ class ContributorFactory(factory.django.DjangoModelFactory):
country_of_employment
=
factory
.
Iterator
(
list
(
COUNTRIES
))
affiliation
=
factory
.
Faker
(
'
company
'
)
class
Meta
:
model
=
Contributor
django_get_or_create
=
(
'
user
'
,)
class
VettingEditorFactory
(
ContributorFactory
):
@factory.post_generation
...
...
@@ -32,9 +36,6 @@ class VettingEditorFactory(ContributorFactory):
class
UserFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
get_user_model
()
username
=
factory
.
Faker
(
'
user_name
'
)
password
=
factory
.
PostGenerationMethodCall
(
'
set_password
'
,
'
adm1n
'
)
email
=
factory
.
Faker
(
'
safe_email
'
)
...
...
@@ -44,6 +45,9 @@ class UserFactory(factory.django.DjangoModelFactory):
# When user object is created, associate new Contributor object to it.
contributor
=
factory
.
RelatedFactory
(
ContributorFactory
,
'
user
'
)
class
Meta
:
model
=
get_user_model
()
@factory.post_generation
def
groups
(
self
,
create
,
extracted
,
**
kwargs
):
# If the object is not saved, we cannot use many-to-many relationship.
...
...
@@ -58,17 +62,27 @@ class UserFactory(factory.django.DjangoModelFactory):
class
EditorialCollegeFactory
(
factory
.
django
.
DjangoModelFactory
):
discipline
=
random
.
choice
([
'
Physics
'
,
'
Chemistry
'
,
'
Medicine
'
])
class
Meta
:
model
=
EditorialCollege
django_get_or_create
=
(
'
discipline
'
,
)
discipline
=
random
.
choice
([
'
Physics
'
,
'
Chemistry
'
,
'
Medicine
'
])
class
EditorialCollegeFellowshipFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
EditorialCollegeFellowship
college
=
factory
.
Iterator
(
EditorialCollege
.
objects
.
all
())
contributor
=
factory
.
Iterator
(
Contributor
.
objects
.
exclude
(
user__username
=
'
deleted
'
).
order_by
(
'
?
'
))
class
Meta
:
model
=
EditorialCollegeFellowship
class
SubmissionRemarkFactory
(
factory
.
django
.
DjangoModelFactory
):
contributor
=
factory
.
Iterator
(
Contributor
.
objects
.
all
())
submission
=
factory
.
Iterator
(
Submission
.
objects
.
all
())
date
=
factory
.
Faker
(
'
date_time_this_decade
'
)
remark
=
factory
.
lazy_attribute
(
lambda
x
:
Faker
().
paragraph
())
class
Meta
:
model
=
Remark
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