-
Notifications
You must be signed in to change notification settings - Fork 12
feat: test framework with test factory #72
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
363f689
feat(tests): add UserFactory and FPTeamFactory via frappe_factory_bot
harshtandiya d08ef88
refactor(tests): use UserFactory in test_roles
harshtandiya 2a82f42
refactor(tests): use factories in TestTeamInvitations
harshtandiya a9af6c4
fix(hooks): add required_apps for frappe_factory_bot
harshtandiya 71e6fdc
ci: fetch frappe_factory_bot before installing forms_pro
harshtandiya 5b2194b
docs: update README with local test instructions and installation ste…
harshtandiya 986a15c
chore: remove del_override
harshtandiya b6f964f
refactor: tests
harshtandiya d55b89e
chore: refactor test_fp_team
harshtandiya 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,4 @@ | ||
| from forms_pro.tests.factories.fp_team_factory import FPTeamFactory | ||
| from forms_pro.tests.factories.user_factory import UserFactory | ||
|
|
||
| __all__ = ["FPTeamFactory", "UserFactory"] |
This file contains hidden or 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,14 @@ | ||
| from typing import Any | ||
|
|
||
| from faker import Faker | ||
| from frappe_factory_bot.frappe_factory_bot.base_factory import BaseFactory | ||
|
|
||
| _fake = Faker() | ||
|
|
||
|
|
||
| class FPTeamFactory(BaseFactory): | ||
| doctype = "FP Team" | ||
|
|
||
| @property | ||
| def default_attributes(self) -> dict[str, Any]: | ||
| return {"team_name": f"{_fake.word().capitalize()} Team"} |
This file contains hidden or 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,26 @@ | ||
| from typing import Any | ||
|
|
||
| from faker import Faker | ||
| from frappe_factory_bot.frappe_factory_bot.base_factory import BaseFactory | ||
|
|
||
| from forms_pro.roles import FORMS_PRO_ROLE | ||
|
|
||
| _fake = Faker() | ||
|
|
||
|
|
||
| class UserFactory(BaseFactory): | ||
| doctype = "User" | ||
|
|
||
| @property | ||
| def default_attributes(self) -> dict[str, Any]: | ||
| return { | ||
| "email": _fake.unique.email(), | ||
| "first_name": _fake.first_name(), | ||
| "last_name": _fake.last_name(), | ||
| } | ||
|
|
||
| @property | ||
| def with_forms_pro_role(self) -> dict[str, Any]: | ||
| # Frappe accepts child table rows as dicts in the initial doc dict. | ||
| # on_update fires with the role already set, so the default team is created. | ||
| return {"roles": [{"role": FORMS_PRO_ROLE}]} |
This file contains hidden or 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,29 @@ | ||
| from typing import Any | ||
|
|
||
| from faker import Faker | ||
| from frappe_factory_bot.frappe_factory_bot.base_factory import BaseFactory | ||
|
|
||
| from forms_pro.roles import FORMS_PRO_ROLE | ||
|
|
||
| _fake = Faker() | ||
|
|
||
|
|
||
| class UserInvitationFactory(BaseFactory): | ||
| doctype = "User Invitation" | ||
|
|
||
| @property | ||
| def default_attributes(self) -> dict[str, Any]: | ||
| return { | ||
| "email": self.overrides.get("email", _fake.unique.email()), | ||
| "redirect_to_path": self.overrides.get("redirect_to_path", "/forms"), | ||
| "invited_by": self.overrides.get("invited_by") or "Administrator", | ||
| "status": self.overrides.get("status") or "Pending", | ||
| } | ||
|
|
||
| @property | ||
| def to_forms_pro_app(self) -> dict[str, Any]: | ||
| return { | ||
| "app_name": "forms_pro", | ||
| "redirect_to_path": "/forms", | ||
| "roles": [{"role": FORMS_PRO_ROLE}], | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: BuildWithHussain/forms_pro
Length of output: 349
Pin
frappe_factory_botto an immutable ref from a trusted source.Line 93 uses a mutable
mainbranch from a personal fork, which makes builds non-reproducible and weakens supply-chain safety. Pin to a version tag and use a trusted upstream repository.Suggested change
🤖 Prompt for AI Agents