[英]Django and Python-Social-Auth redirect if I make custom pipeline
[英]How to test a custom python-social-auth pipeline?
首先 - 假設管道機制有效,因此您無需進行測試。
第二 - 找出你需要傳遞給你的函數的參數。
第三 - 寫下你的考試。
使用Django TestCase,您的測試將如下所示。
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)
這將是您的基本結構,沒有更多關於您的管道所做的事情的信息。 無論如何,您都可以了解Django TestCase的工作原理。
要消除這一點的是你不需要測試它如何與實際的管道本身相結合,這是管道要知道的,你只需要擔心你的功能。 如果由於某種原因需要擁有管道對象,請模擬它 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.