Skip to content
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
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

Walexero
Copy link

@Walexero Walexero commented Oct 5, 2022

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.

@brylie brylie marked this pull request as draft October 5, 2022 21:47
@Walexero Walexero marked this pull request as ready for review October 6, 2022 09:58
Copy link
Member

@brylie brylie left a 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.

@Walexero Walexero changed the title Closes #1350 & #1346 Add development fixtures for #1350 & Add django-browser-reload #1346 Oct 7, 2022
@Walexero
Copy link
Author

Walexero commented Oct 7, 2022

Title and Description has been added

Copy link
Member

@brylie brylie left a 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.

Comment on lines 12 to 19
# Another, different, factory for the same object
class AdminFactory(factory.Factory):
class Meta:
model = models.User

first_name = 'Admin'
last_name = 'User'
admin = True
Copy link
Member

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?

Copy link
Author

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

Copy link
Author

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


class UserFactory(factory.Factory):
class Meta:
model = models.User
Copy link
Member

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.


class UserFactory(factory.Factory):
class Meta:
model = models.User
Copy link
Member

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.

Comment on lines 12 to 19
# Another, different, factory for the same object
class AdminFactory(factory.Factory):
class Meta:
model = models.User

first_name = 'Admin'
last_name = 'User'
admin = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably unnecessary.

Suggested change
# Another, different, factory for the same object
class AdminFactory(factory.Factory):
class Meta:
model = models.User
first_name = 'Admin'
last_name = 'User'
admin = True


class UserFactory(factory.Factory):
class Meta:
model = models.User
Copy link
Member

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.

@brylie brylie marked this pull request as draft October 7, 2022 16:39
@brylie
Copy link
Member

brylie commented Oct 7, 2022

Converting to draft to indicate the PR is still in progress.

@Walexero Walexero marked this pull request as ready for review October 10, 2022 00:46
model = models.User
model = models.Profile

user = factory.RelatedFactory(UserFactory, factory_related_name="profile")
Copy link
Member

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"?

Suggested change
user = factory.RelatedFactory(UserFactory, factory_related_name="profile")
profile = factory.RelatedFactory(UserFactory, factory_related_name="profile")

Copy link
Author

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

Copy link
Author

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

name = factory.Iterator(["Politics","Voting","Referendum"])
Copy link
Member

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

Suggested change
name = factory.Iterator(["Politics","Voting","Referendum"])
name = factory.Iterator(["Politics","Voting","Referendum"])

civi = factory.SubFactory(CiviFactory)
activity_type = factory.fuzzy.FuzzyChoice(models.Notification.activity_CHOICES, getter=lambda c: c[0])
read = factory.Faker().pybool()
Copy link
Member

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

Suggested change
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)
Copy link
Member

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

Suggested change
return super().create(**kwargs)
return super().create(**kwargs)

@Walexero
Copy link
Author

all the above issues have been addressed

# Add the iterable of categores using bulk addition
self.categories.add(*extracted)

#taggablemanager()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#taggablemanager()

Copy link
Author

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

Comment on lines 65 to 70









Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

activity_type = factory.fuzzy.FuzzyChoice(models.Notification.activity_CHOICES, getter=lambda c: c[0])
read = factory.Faker().pybool()


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines 15 to 16


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

# Add the iterable of categores using bulk addition
self.facts.add(*extracted)

#taggablemanager()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#taggablemanager()

authors = factory.SubFactory(UserFactory)
thread = factory.SubFactory(ThreadFactory)

#taggablemanager()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#taggablemanager()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would remove it

Comment on lines 167 to 168


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@gorkemarslan
Copy link
Collaborator

Could you update your branch to run the latest pipeline in our project? Otherwise, tests fail and we cannot see formating issues.

@Walexero
Copy link
Author

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?

@brylie brylie reopened this Oct 11, 2022
@brylie
Copy link
Member

brylie commented Oct 11, 2022

I reopened the pull request. It looks like the CI is failing with the following error.

ModuleNotFoundError: No module named 'django_browser_reload'

@Walexero
Copy link
Author

okay, maybe i should try installing it with poetry if pip doesn't make the module findable

@brylie
Copy link
Member

brylie commented Oct 11, 2022

Yes, we use Poetry to manage the dependencies for this project.

@Walexero
Copy link
Author

i have added the changes with django-browser-reload added with poetry so i think that should solve the CI issue

@Walexero
Copy link
Author

hello, do you still need me working on this issue?

@Walexero Walexero requested a review from brylie October 18, 2022 13:53
@Walexero Walexero requested review from gorkemarslan and brylie and removed request for brylie and gorkemarslan October 18, 2022 13:53
pyproject.toml Show resolved Hide resolved
@Walexero
Copy link
Author

Walexero commented May 7, 2023

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

@brylie
Copy link
Member

brylie commented May 7, 2023

It looks like there are many files with conflicts, unfortunately

@Walexero
Copy link
Author

How should I go about resolving this or what should be done? If you can put me through

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add development fixtures
3 participants