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
17dc9c51
Commit
17dc9c51
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add factories for all proceedings models
parent
ea619738
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
scipost_django/proceedings/factories.py
+35
-12
35 additions, 12 deletions
scipost_django/proceedings/factories.py
scipost_django/proceedings/tests/test_factories.py
+11
-0
11 additions, 0 deletions
scipost_django/proceedings/tests/test_factories.py
with
46 additions
and
12 deletions
scipost_django/proceedings/factories.py
+
35
−
12
View file @
17dc9c51
...
@@ -5,40 +5,63 @@ __license__ = "AGPL v3"
...
@@ -5,40 +5,63 @@ __license__ = "AGPL v3"
import
random
import
random
import
factory
import
factory
from
journals.factories
import
IssueFactory
from
colleges.factories
import
FellowshipFactory
from
common.faker
import
fake
from
journals.factories
import
JournalIssueFactory
from
proceedings.models
import
Proceedings
from
proceedings.models
import
Proceedings
import
datetime
class
ProceedingsFactory
(
factory
.
django
.
DjangoModelFactory
):
class
ProceedingsFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
class
Meta
:
model
=
Proceedings
model
=
Proceedings
issue
=
factory
.
SubFactory
(
IssueFactory
)
issue
=
factory
.
SubFactory
(
JournalIssueFactory
)
minimum_referees
=
2
event_name
=
factory
.
Faker
(
"
company
"
)
event_name
=
factory
.
Faker
(
"
company
"
)
event_suffix
=
factory
.
Faker
(
"
company_suffix
"
)
event_suffix
=
factory
.
Faker
(
"
company_suffix
"
)
event_description
=
factory
.
Faker
(
"
paragraph
"
)
event_description
=
factory
.
Faker
(
"
paragraph
"
)
event_start_date
=
factory
.
Faker
(
"
date_this_decade
"
)
event_start_date
=
factory
.
Faker
(
"
date_this_decade
"
)
event_end_date
=
factory
.
LazyAttribute
(
event_end_date
=
factory
.
LazyAttribute
(
lambda
self
:
self
.
event_start_date
lambda
self
:
fake
.
aware
.
date_between
(
+
datetime
.
timedelta
(
start_date
=
self
.
event_start_date
,
end_date
=
"
+1y
"
seconds
=
random
.
randint
(
0
,
60
*
60
*
24
*
365
),
)
)
)
)
logo
=
factory
.
django
.
ImageField
()
picture
=
factory
.
django
.
ImageField
()
picture_credit
=
factory
.
Faker
(
"
sentence
"
)
cover_image
=
factory
.
django
.
ImageField
()
submissions_open
=
factory
.
Faker
(
"
date_this_decade
"
)
submissions_open
=
factory
.
Faker
(
"
date_this_decade
"
)
submissions_close
=
factory
.
LazyAttribute
(
submissions_close
=
factory
.
LazyAttribute
(
lambda
self
:
self
.
submissions_open
lambda
self
:
fake
.
aware
.
date_between
(
+
datetime
.
timedelta
(
start_date
=
self
.
submissions_open
,
end_date
=
"
+1y
"
seconds
=
random
.
randint
(
0
,
60
*
60
*
24
*
365
),
)
)
)
)
submissions_deadline
=
factory
.
LazyAttribute
(
submissions_deadline
=
factory
.
LazyAttribute
(
lambda
self
:
self
.
submissions_close
lambda
self
:
fake
.
aware
.
date_between
(
+
datetime
.
timedelta
(
start_date
=
self
.
submissions_close
,
end_date
=
"
+14d
"
seconds
=
random
.
randint
(
0
,
60
*
60
*
24
*
365
),
)
)
)
)
preface_title
=
factory
.
Faker
(
"
sentence
"
)
preface_title
=
factory
.
Faker
(
"
sentence
"
)
preface_text
=
factory
.
Faker
(
"
paragraph
"
)
preface_text
=
factory
.
Faker
(
"
paragraph
"
)
template_latex_tgz
=
factory
.
django
.
FileField
()
# lead_fellow = factory.SubFactory("colleges.factories.SeniorFellowshipFactory")
@factory.post_generation
def
fellowships
(
self
,
create
,
extracted
,
**
kwargs
):
if
not
create
:
return
if
extracted
:
for
fellowship
in
extracted
:
self
.
fellowships
.
add
(
fellowship
)
else
:
self
.
fellowships
.
add
(
*
FellowshipFactory
.
create_batch
(
random
.
randint
(
1
,
5
),
college
=
self
.
issue
.
in_journal
.
college
,
)
)
This diff is collapsed.
Click to expand it.
scipost_django/proceedings/tests/test_factories.py
0 → 100644
+
11
−
0
View file @
17dc9c51
__copyright__
=
"
Copyright © Stichting SciPost (SciPost Foundation)
"
__license__
=
"
AGPL v3
"
from
django.test
import
TestCase
from
proceedings.factories
import
ProceedingsFactory
class
TestProceedingsFactory
(
TestCase
):
def
test_can_create_proceedingss
(
self
):
proceedings
=
ProceedingsFactory
()
self
.
assertIsNotNone
(
proceedings
)
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