So, I have created a custom pipeline for saving user's social profile data fetched from extra_data
attribute of the user.social_auth
model. I have thoroughly tested it, but manually.
How do I automate testing for my custom pipeline, by using regular django.test.TestCase
?
How to test if the normal pipeline works? User signup, login, etc.?
I did search a lot but didn't find any relevant similar questions let alone tutorials or documentation for it.
Update - I posted the question as an issue on github and found out that functionality for pipeline testing exists. Now I only need to figure out how to use it for my purpose.
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 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 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With