-
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
base: develop
Are you sure you want to change the base?
Conversation
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.
Please add a title and description that indicate what this pull request resolves.
Title and Description has been added |
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.
The factories should reference the actual project models. They currently seem to be example codes from the Factory Boy documentation. Let's take the next step and create factories for the CiviWiki models found in the models.py
files.
project/categories/factory.py
Outdated
# Another, different, factory for the same object | ||
class AdminFactory(factory.Factory): | ||
class Meta: | ||
model = models.User | ||
|
||
first_name = 'Admin' | ||
last_name = 'User' | ||
admin = True |
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.
What is this factory used for?
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.
i misunderstood, the required implementation for the factory, the new commit contains the right approach
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.
i misunderstood, the required implementation for the factory, the new commit contains the right approach
project/categories/factory.py
Outdated
|
||
class UserFactory(factory.Factory): | ||
class Meta: | ||
model = models.User |
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.
What model in the categories app are we building this factory for? See project/categories/models.py
where the models are defined.
project/notification/factory.py
Outdated
|
||
class UserFactory(factory.Factory): | ||
class Meta: | ||
model = models.User |
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.
What model in the notifications app are we building this factory for? See project/notifications/models.py
where the models are defined.
project/notification/factory.py
Outdated
# Another, different, factory for the same object | ||
class AdminFactory(factory.Factory): | ||
class Meta: | ||
model = models.User | ||
|
||
first_name = 'Admin' | ||
last_name = 'User' | ||
admin = True |
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.
This is probably unnecessary.
# Another, different, factory for the same object | |
class AdminFactory(factory.Factory): | |
class Meta: | |
model = models.User | |
first_name = 'Admin' | |
last_name = 'User' | |
admin = True |
project/threads/factory.py
Outdated
|
||
class UserFactory(factory.Factory): | ||
class Meta: | ||
model = models.User |
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.
What model in the threads app are we building this factory for? See project/threads/models.py
where the models are defined.
Converting to draft to indicate the PR is still in progress. |
project/accounts/factory.py
Outdated
model = models.User | ||
model = models.Profile | ||
|
||
user = factory.RelatedFactory(UserFactory, factory_related_name="profile") |
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.
Should this field be called "profile" since it has the related name "profile"?
user = factory.RelatedFactory(UserFactory, factory_related_name="profile") | |
profile = factory.RelatedFactory(UserFactory, factory_related_name="profile") |
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.
The field in the profile model is:
user = models.OneToOneField(User,
on_delete=models.CASCADE,
related_name="profile")
That was the reason i had it done in that way, i can't find enough resource to help with a OneToOneField using factory_boy plus i am conflicted as to if i have to also include a field in the UserFactory but the model.User only contains a link to the database
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.
Also should i change the name of each field which has a related_name to the related_name
project/categories/factory.py
Outdated
name = factory.Iterator(["Politics","Voting","Referendum"]) |
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.
Add new line at end of file
name = factory.Iterator(["Politics","Voting","Referendum"]) | |
name = factory.Iterator(["Politics","Voting","Referendum"]) | |
project/notification/factory.py
Outdated
civi = factory.SubFactory(CiviFactory) | ||
activity_type = factory.fuzzy.FuzzyChoice(models.Notification.activity_CHOICES, getter=lambda c: c[0]) | ||
read = factory.Faker().pybool() |
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.
Add new line at end of file
read = factory.Faker().pybool() | |
read = factory.Faker().pybool() | |
def create(cls, _fake_time=None, **kwargs): | ||
wrapper = partial(freeze_time,time_to_freeze=_fake_time) if _fake_time else suppress | ||
with wrapper(_fake_time): | ||
return super().create(**kwargs) |
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.
Make sure all files have an empty line at the end
return super().create(**kwargs) | |
return super().create(**kwargs) | |
all the above issues have been addressed |
project/accounts/factory.py
Outdated
# Add the iterable of categores using bulk addition | ||
self.categories.add(*extracted) | ||
|
||
#taggablemanager() |
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.
#taggablemanager() |
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.
it is meant to refer to the tags field and to indicate its the code for that field
project/accounts/factory.py
Outdated
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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.
activity_type = factory.fuzzy.FuzzyChoice(models.Notification.activity_CHOICES, getter=lambda c: c[0]) | ||
read = factory.Faker().pybool() | ||
|
||
|
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.
|
||
|
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.
project/threads/factory.py
Outdated
# Add the iterable of categores using bulk addition | ||
self.facts.add(*extracted) | ||
|
||
#taggablemanager() |
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.
#taggablemanager() |
project/threads/factory.py
Outdated
authors = factory.SubFactory(UserFactory) | ||
thread = factory.SubFactory(ThreadFactory) | ||
|
||
#taggablemanager() |
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.
#taggablemanager() |
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.
would remove it
project/threads/factory.py
Outdated
|
||
|
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.
Could you update your branch to run the latest pipeline in our project? Otherwise, tests fail and we cannot see formating issues. |
I synced my repo to include the latest changes, but it seems to have closed this pull request, is there anything i can do to solve this? |
I reopened the pull request. It looks like the CI is failing with the following error.
|
okay, maybe i should try installing it with poetry if pip doesn't make the module findable |
Yes, we use Poetry to manage the dependencies for this project. |
…iWiki#1350 and Add django-browser-reload CiviWiki#1346
i have added the changes with django-browser-reload added with poetry so i think that should solve the CI issue |
hello, do you still need me working on this issue? |
Hi, can we fix any issues and close this issue. if there's any steps you need me to take, or resolve any conflicts with the code i pushed. I am available to do that |
It looks like there are many files with conflicts, unfortunately |
How should I go about resolving this or what should be done? If you can put me through |
Closes #1350
Description
Added development fixtures for issue #1350 by adding factory_boy to this project and defining it in the required apps.
Added django-browser-reload to this project with the provided installation instructions.