-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add development fixtures for #1350 & Add django-browser-reload #1346 #1401
Open
Walexero
wants to merge
4
commits into
CiviWiki:develop
Choose a base branch
from
Walexero:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
462c77c
Updated repo to upstream commits with fix for issue:#1346
Walexero 021531d
Synced repo with Upstream and Closes:Add development fixtures for #13…
Walexero aa323d5
Synced repo with Upstream and Closes:Add development fixtures for #13…
Walexero f20a8ef
Added development fixtures for #1350
Walexero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from turtle import color | ||
import factory | ||
from . import models | ||
from categories.factory import CategoryFactory | ||
|
||
class UserFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = models.User | ||
|
||
|
||
class ProfileFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = models.Profile | ||
|
||
profile = factory.RelatedFactory(UserFactory, factory_related_name="profile") | ||
first_name = factory.Faker('first_name') | ||
last_name = factory.Faker('last_name') | ||
about_me = factory.Faker('sentence', nb_words=20) | ||
|
||
@factory.post_generation | ||
def categories(self, create, extracted, **kwargs): | ||
if not create or not extracted: | ||
# Simple build, or nothing to add, do nothing. | ||
return | ||
|
||
# Add the iterable of categores using bulk addition | ||
self.categories.add(*extracted) | ||
|
||
@factory.post_generation | ||
def tags(self, create, extracted, **kwargs): | ||
self.tags.add(u'abc, cde', u'xzy') | ||
|
||
@factory.post_generation | ||
def followers(self, create, extracted, **kwargs): | ||
if not create or not extracted: | ||
# Simple build, or nothing to add, do nothing. | ||
return | ||
|
||
# Add the iterable of following using bulk addition | ||
self.followers.add(*extracted) | ||
|
||
@factory.post_generation | ||
def following(self, create, extracted, **kwargs): | ||
if not create or not extracted: | ||
# Simple build, or nothing to add, do nothing. | ||
return | ||
|
||
# Add the iterable of following using bulk addition | ||
self.following.add(*extracted) | ||
|
||
is_verified = factory.Faker().pybool() | ||
full_profile = factory.Faker().pybool() | ||
profile_image = factory.django.ImageField(color='blue') | ||
profile_image_thumb = factory.django.ImageField(color='blue') | ||
|
||
#defining the ProfileManager for the objects field | ||
@classmethod | ||
def _create(cls, model_class, *args, **kwargs): | ||
"""Override the default ``_create`` with our custom call.""" | ||
manager = cls._get_manager(model_class) | ||
# The default would use ``manager.create(*args, **kwargs)`` | ||
return manager.summarize(*args, **kwargs) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import factory | ||
from . import models | ||
from shared_factory.shared_factory import FreezeTimeModelFactory | ||
|
||
class CategoryFactory(FreezeTimeModelFactory): | ||
class Meta: | ||
model = models.Category | ||
|
||
name = factory.Iterator(["Politics","Voting","Referendum"]) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import factory | ||
from . import models | ||
from shared_factory.shared_factory import FreezeTimeModelFactory | ||
from accounts.factory import ProfileFactory | ||
from threads.factory import ThreadFactory, CiviFactory | ||
|
||
class NotificationFactory(FreezeTimeModelFactory): | ||
class Meta: | ||
model = models.Notification | ||
|
||
account = factory.SubFactory(ProfileFactory) | ||
thread = factory.SubFactory(ThreadFactory) | ||
civi = factory.SubFactory(CiviFactory) | ||
activity_type = factory.fuzzy.FuzzyChoice(models.Notification.activity_CHOICES, getter=lambda c: c[0]) | ||
read = factory.Faker().pybool() | ||
|
||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
from turtle import title | ||
import factory | ||
from . import models | ||
from shared_factory.shared_factory import FreezeTimeModelFactory | ||
from accounts.factory import UserFactory | ||
from categories.factory import CategoryFactory | ||
from core.constants import CIVI_TYPES | ||
|
||
class FactFactory(FreezeTimeModelFactory): | ||
class Meta: | ||
model = models.Fact | ||
|
||
body = factory.Faker('sentence', nb_words=100) | ||
|
||
|
||
class ThreadFactory(FreezeTimeModelFactory): | ||
class Meta: | ||
model = models.Thread | ||
|
||
author = factory.SubFactory(UserFactory) | ||
category = factory.SubFactory(CategoryFactory) | ||
|
||
@factory.post_generation | ||
def facts(self, create, extracted, **kwargs): | ||
if not create or not extracted: | ||
# Simple build, or nothing to add, do nothing. | ||
return | ||
# Add the iterable of categores using bulk addition | ||
self.facts.add(*extracted) | ||
|
||
@factory.post_generation | ||
def tags(self, create, extracted, **kwargs): | ||
self.tags.add(u'abc, cde', u'xzy') | ||
|
||
title = factory.Faker('sentence', nb_words= 4) | ||
summary = factory.Faker('sentence', nb_words= 30) | ||
image = factory.django.ImageField(color='blue') | ||
is_draft = factory.Faker().pybool() | ||
num_views = factory.fuzzy.FuzzyInteger(0, 30) | ||
num_civis = factory.fuzzy.FuzzyInteger(0, 30) | ||
num_solutions = factory.fuzzy.FuzzyInteger(0, 30) | ||
|
||
#defining the ThreadManager for the objects field | ||
@classmethod | ||
def _create(cls, model_class, *args, **kwargs): | ||
"""Override the default ``_create`` with our custom call.""" | ||
manager = cls._get_manager(model_class) | ||
# The default would use ``manager.create(*args, **kwargs)`` | ||
return manager.summarize(*args, **kwargs) | ||
|
||
|
||
class CiviFactory(FreezeTimeModelFactory): | ||
class Meta: | ||
model = models.Civi | ||
|
||
authors = factory.SubFactory(UserFactory) | ||
thread = factory.SubFactory(ThreadFactory) | ||
|
||
@factory.post_generation | ||
def tags(self, create, extracted, **kwargs): | ||
self.tags.add(u'abc, cde', u'xzy') | ||
|
||
@factory.post_generation | ||
def linked_civis(self, create, extracted, **kwargs): | ||
if not create or not extracted: | ||
# Simple build, or nothing to add, do nothing. | ||
return | ||
# Add the iterable of following using bulk addition | ||
self.linked_civis.add(*extracted) | ||
|
||
title = factory.Faker('sentence', nb_words= 4) | ||
body = factory.Faker('sentence', nb_words= 100) | ||
c_type = factory.fuzzy.FuzzyChoice(CIVI_TYPES, getter=lambda c: c[0]) | ||
votes_vneg = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_neg = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_neutral = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_pos = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_vpos = factory.fuzzy.FuzzyInteger(0, 30) | ||
|
||
#Please verify if this is the right implementation for votes = property(_get_votes) | ||
@classmethod | ||
def _create(cls, model_class, *args, **kwargs): | ||
votes = model_class(*args, **kwargs) | ||
return votes._get_votes() | ||
|
||
#defining the CiViManager for the objects field | ||
@classmethod | ||
def _create(cls, model_class, *args, **kwargs): | ||
"""Override the default ``_create`` with our custom call.""" | ||
manager = cls._get_manager(model_class) | ||
# The default would use ``manager.create(*args, **kwargs)`` | ||
return manager.summarize(*args, **kwargs) | ||
|
||
|
||
class ResponseFactory(factory.Factory): | ||
class Meta: | ||
model = models.Response | ||
|
||
author = factory.SubFactory(UserFactory) | ||
civi = factory.SubFactory(CiviFactory) | ||
title = factory.Faker('sentence', nb_words= 4) | ||
body = factory.Faker('sentence', nb_words= 100) | ||
votes_vneg = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_neg = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_neutral = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_pos = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_vpos = factory.fuzzy.FuzzyInteger(0, 30) | ||
|
||
|
||
class CiviImageFactory(FreezeTimeModelFactory): | ||
class Meta: | ||
model = models.CiviImage | ||
|
||
civi = factory.SubFactory(CiviFactory) | ||
title = factory.Faker('sentence', nb_words= 4) | ||
image = factory.django.ImageField(color='blue') | ||
|
||
|
||
#defining the CiViManager for the objects field | ||
@classmethod | ||
def _create(cls, model_class, *args, **kwargs): | ||
"""Override the default ``_create`` with our custom call.""" | ||
manager = cls._get_manager(model_class) | ||
# The default would use ``manager.create(*args, **kwargs)`` | ||
return manager.get_images(*args, **kwargs) | ||
|
||
|
||
class ActivityFactory(FreezeTimeModelFactory): | ||
class Meta: | ||
model = models.Activity | ||
|
||
user = factory.SubFactory(UserFactory) | ||
thread = factory.SubFactory(ThreadFactory) | ||
civi = factory.SubFactory(CiviFactory) | ||
activity_type = factory.fuzzy.FuzzyChoice(models.Activity.activity_CHOICES) | ||
read = factory.Faker().pybool() | ||
|
||
|
||
class RebuttalFactory(FreezeTimeModelFactory): | ||
class Meta: | ||
model = models.Rebuttal | ||
|
||
author = factory.SubFactory(UserFactory) | ||
response = factory.SubFactory(ResponseFactory) | ||
body = factory.Faker('sentence', nb_words= 100) | ||
votes_vneg = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_neg = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_neutral = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_pos = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_vpos = factory.fuzzy.FuzzyInteger(0, 30) | ||
|
||
|
||
class RationaleFactory(FreezeTimeModelFactory): | ||
class Meta: | ||
model = models.Rationale | ||
|
||
title = factory.Faker('sentence', nb_words= 4) | ||
body = factory.Faker('sentence', nb_words= 100) | ||
votes_vneg = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_neg = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_neutral = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_pos = factory.fuzzy.FuzzyInteger(0, 30) | ||
votes_vpos = factory.fuzzy.FuzzyInteger(0, 30) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.