How to test python-social-auth native protocol?
So, I created a custom pipeline to store the user's social profile data obtained from the extra_data
model attribute user.social_auth
. I tested it thoroughly, but manually.
-
How do I automate testing for my custom pipeline using a regular pipeline
django.test.TestCase
? -
How to check if a normal pipeline is working? User registration, login, etc.
I searched a lot but couldn't find any relevant similar questions, let alone tutorials or documentation for this.
Update - I posted the question as a github question and found out that functionality for the testing pipeline exists . Now I only need to figure out how to use it for my purpose.
source to share
First. Let's assume the Pipeline engine is working, so you don't need to test it.
Second - Find out what arguments you need to pass to your function.
Third, write your test.
Using Django TestCase your test will look like this.
from mycustompipeline import pipelinefunction
class MyPipeLineTest(TestCase):
def setUp(self):
self.arg1 = Arg1() #both one and two could be mocks.
self.arg2 = Arg2()
def test_that_my_pipeline_does_something(self):
result = pipelinefunction(self.arg1, self.arg2)
self.assertTrue(result)
This will be your main structure, with no additional information about what your pipeline is doing as well as it gets. You understand how things work with Django TestCase.
Taking a break from that means you don't have to check how it fits with the pipeline itself, which for a pipeline to be aware of, you just worry about its function. And if for some reason you need a pipeline object, mock it .
source to share