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

Create factories and tests for the entities #538

Merged
merged 5 commits into from
Nov 17, 2023

Conversation

marcosquadross
Copy link
Contributor

Contributor checklist


Description

This PR create a new file with de entitites factory and add the tests.

Related issue

Copy link

netlify bot commented Nov 11, 2023

Deploy Preview for activist-org canceled.

Name Link
🔨 Latest commit beac424
🔍 Latest deploy log https://app.netlify.com/sites/activist-org/deploys/655730e0d72b93000714dcbd

Copy link
Contributor

github-actions bot commented Nov 11, 2023

Thank you for the pull request!

The activist team will do our best to address your contribution as soon as we can. The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

If you're not already a member of our public Matrix community, please consider joining! We'd suggest using Element as your Matrix client, and definitely join the General and Development rooms once you're in. It'd be great to have you!

Maintainer checklist

  • The commit messages for the remote branch should be checked to make sure the contributor's email is set up correctly so that they receive credit for their contribution

    • The contributor's name and icon in remote commits should be the same as what appears in the PR
    • If there's a mismatch, the contributor needs to make sure that the email they use for GitHub matches what they have for git config user.email in their local activist repo
  • The TypeScript and formatting workflows within the PR checks do not indicate new errors in the files changed

  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@to-sta
Copy link
Collaborator

to-sta commented Nov 11, 2023

@marcosquadross thank you for the work you put into this 🚀 . I will check the PR in the next days.

Btw, the backend workflow fails because of static type checking, but this is not an issue. factory_boy does not support stub files and therefore, I will add the files to be ignored in the mypy config.

@to-sta
Copy link
Collaborator

to-sta commented Nov 12, 2023

@andrewtavis since there are a lot of reference to other factories (subfactories), we need to wait till the rest of the factories are done, before we can properly test if it works.

I would say we can merge this after the change request and than keep the issue open.

@andrewtavis
Copy link
Member

Yes I'll merge later, @to-sta :)

@to-sta
Copy link
Collaborator

to-sta commented Nov 17, 2023

@marcosquadross I made some minor adjustments. Thanks for your work on this 😃


class OrganizationFactory(factory.django.DjangoModelFactory):
class Meta:
model: Organization
Copy link
Collaborator

Choose a reason for hiding this comment

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

@marcosquadross saw a typo here, model should be assigned to Organization. Generally I would recommand you to test your implementation. When you run pytest, you would see that it fails.

class Meta:
     model = Organization

You can also use the django shell (python manage.py shell) to test your factories.


# Create your tests here.
@pytest.mark.django_db
Copy link
Collaborator

Choose a reason for hiding this comment

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

When you use the build() method you do not need the db marker 😉. It's needed for the create method, with build you aren't creating entries in the database.

Copy link
Member

@andrewtavis andrewtavis left a comment

Choose a reason for hiding this comment

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

Thank you for the work here, @marcosquadross! Hope we can work with you again soon 😊 And thanks for the review, @to-sta!

@andrewtavis andrewtavis merged commit 4ee0bb6 into activist-org:main Nov 17, 2023
5 of 6 checks passed
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.

3 participants