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

Calling callback functions directly (eg. for tests) #1839

Merged
merged 5 commits into from
May 6, 2022
Merged

Calling callback functions directly (eg. for tests) #1839

merged 5 commits into from
May 6, 2022

Conversation

marekpiotrowski
Copy link
Contributor

As per #1195, sometimes there's a need to unit-test some of the callback functions. What we're doing in the team right now is adding a wrapper so that the callback calls a wrapper and we're able to call the function outside of the dash framework.

Initially I thought that what has been suggested in the issue description would be more appropriate (so, having .inner attribute on the returned value), but eventually the other suggested solution is more "intuitive" (in the former case, we'd have to update the documentation as well :( )

The solution is not ideal, obviously, cause if somebody uses the callback context within the callbacks which he/she intends to call in isolation, it's gonna crash (unless it's somehow mocked in the calling context)

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Implement as suggested in the issue discussion
    • Adjust unit tests
    • Add integration test
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

Thanks @marekpiotrowski! And apologies for taking so long to look at this. Great idea to make this change, I just simplified the test and added a changelog entry. 💃

@alexcjohnson alexcjohnson merged commit 4462a0f into plotly:dev May 6, 2022
@marekpiotrowski
Copy link
Contributor Author

No problem at all, thanks for checking! Cheers.

The idea wasn't mine at all - it's all in the linked issue (#1195). Not sure about your processes but would probably make sense to update its status?

By the way, the framework is awesome, keep up the great work you're doing!

@alexcjohnson
Copy link
Collaborator

Haha ok well thanks for resurrecting the idea and reminding me what I proposed 2 years ago!

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.

2 participants