def test_call(self): res_auth = MagicMock(spec=ResAuth, sessionid=None, csrftoken=None, url="www.abc.com") resp = ResAuth.__call__(res_auth, MagicMock(headers={})) self.assertDictEqual(resp.headers, {'referer': 'www.abc.com'}) res_auth = MagicMock(spec=ResAuth, sessionid='my-id', csrftoken='my-token', url="abc.com") resp = ResAuth.__call__(res_auth, MagicMock(headers={})) self.assertDictEqual(resp.headers, { 'X-CSRFToken': 'my-token', 'referer': 'abc.com', 'Cookie': 'csrftoken=my-token; sessionid=my-id' })
def test_call(self): res_auth = MagicMock( spec=ResAuth, sessionid=None, csrftoken=None, url="www.abc.com" ) resp = ResAuth.__call__(res_auth, MagicMock(headers={})) self.assertDictEqual(resp.headers, {"referer": "www.abc.com"}) res_auth = MagicMock( spec=ResAuth, sessionid="my-id", csrftoken="my-token", url="abc.com" ) resp = ResAuth.__call__(res_auth, MagicMock(headers={})) self.assertDictEqual( resp.headers, {"X-CSRFToken": "my-token", "referer": "abc.com"}, )
def test_call(self): res_auth = MagicMock(spec=ResAuth, sessionid="", csrftoken="") ResAuth.__call__(res_auth, MagicMock(headers={}))