How to test a custom python-social-auth pipeline? How to test a custom python-social-auth pipeline? django django

How to test a custom python-social-auth pipeline?


First - Assume that the Pipeline mechanism works so you don't need to test that.

Second - Find out what arguments you need to pass to your function.

Third - Write your test.

Using Django TestCase your test would look like this.

from mycustompipeline import pipelinefunctionclass 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 would be your basic structure, without more information on what your pipeline does this is as good as it gets.You get the gist of how things work with Django TestCase anyways.

The thing to take away from this is that you don't need to test how it fits together with the actual pipeline itself, that's for the pipeline to know about, you just worry about your function. And if you need to have a pipeline object for some reason, mock it.