🤠 good day folks. what is the best approach for h...
# support-questions-legacy
d
🤠 good day folks. what is the best approach for handling unit tests with supertokens python SDK? unfortunately i have procrastinated on this for way too long. is there any easy mechanism to mock the user session? i know about the recipe specific API overrides as I am using some of those to customize the auth flow. is there a way to mock the response for user session as well? Can I override the
verify_session
function in the session.init()?
r
hey @d3adb0y
The best way to do do unit testing it to actually spin up an instance of the core that you can run to.
d
oh geez i was hoping that wasnt going to be the answer lol
but that makes sense
r
yeaaa.. we need to figure out a better way.
d
to not pollute your PRD supertokens
r
but until then..
well, you don't have to run it against the prod core
use the dev core, or spin up your own docker image
you don't even need to connect the core to a db. It can just use the in memory db
d
yeah i have some experience using the python docker plugin
to launch test deps
ill give that a shot.
r
cool
d
most of my endpoints dont even have an explicit dependency on supertokens except for one or two. right now im just refactoring with some class based views in fastapi
to make it easier to disable it on endpoints which dont require integration w auth
thanks as always @rp_st 🙏
but if i was to go that approach and create my own local supertokens instance for testing
wouldnt that still require generating and retrieving the OTP token?
r
it would. And you can override the sendEmail / sendSms functino on the backend to store the OTP in memory (if in testing mode), and then fetch that from your tests somehow
5 Views