Add development fixtures for #1350 & Add django-browser-reload #1346#1401
Add development fixtures for #1350 & Add django-browser-reload #1346#1401Walexero wants to merge 4 commits intoCiviWiki:developfrom
Conversation
brylie
left a comment
There was a problem hiding this comment.
Please add a title and description that indicate what this pull request resolves.
|
Title and Description has been added |
brylie
left a comment
There was a problem hiding this comment.
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 No newline at end of file |
There was a problem hiding this comment.
What is this factory used for?
There was a problem hiding this comment.
i misunderstood, the required implementation for the factory, the new commit contains the right approach
There was a problem hiding this comment.
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.
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.
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 No newline at end of file |
There was a problem hiding this comment.
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.
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.
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.
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.
Also should i change the name of each field which has a related_name to the related_name
project/categories/factory.py
Outdated
| first_name = 'Admin' | ||
| last_name = 'User' | ||
| admin = True No newline at end of file | ||
| name = factory.Iterator(["Politics","Voting","Referendum"]) No newline at end of file |
There was a problem hiding this comment.
Add new line at end of file
| name = factory.Iterator(["Politics","Voting","Referendum"]) | |
| name = factory.Iterator(["Politics","Voting","Referendum"]) | |
project/notification/factory.py
Outdated
| 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() No newline at end of file |
There was a problem hiding this comment.
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) No newline at end of file |
There was a problem hiding this comment.
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.
| #taggablemanager() |
There was a problem hiding this comment.
it is meant to refer to the tags field and to indicate its the code for that field
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
| activity_type = factory.fuzzy.FuzzyChoice(models.Notification.activity_CHOICES, getter=lambda c: c[0]) | ||
| read = factory.Faker().pybool() | ||
|
|
||
|
|
|
|
||
|
|
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.
| #taggablemanager() |
project/threads/factory.py
Outdated
| authors = factory.SubFactory(UserFactory) | ||
| thread = factory.SubFactory(ThreadFactory) | ||
|
|
||
| #taggablemanager() |
There was a problem hiding this comment.
| #taggablemanager() |
project/threads/factory.py
Outdated
|
|
||
|
|
|
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.