def test_initialize_session(self, request):
        request.return_value.status_code = HttpStatusCode.Ok

        class MySession(Session):
            initialize_called = 0

            def initialize(self):
                MySession.initialize_called += 1

        service = Service("foo",
                          auth=mock.MagicMock(token=FAKE_TOKEN),
                          session_class=MySession)
        service.session.get("bar")

        assert MySession.initialize_called == 1
示例#2
0
 def test_session_token(self):
     token = "foo.bar.sig"
     service = Service("foo", auth=MagicMock(token=token))
     self.assertEqual(service.session.headers.get("Authorization"), token)
 def test_session_token(self):
     service = Service("foo", auth=mock.MagicMock(token=FAKE_TOKEN))
     assert service.session.headers.get("Authorization") == add_bearer(
         FAKE_TOKEN)
 def test_client_session_header(self):
     service = Service("foo", auth=mock.MagicMock(token=FAKE_TOKEN))
     assert "X-Client-Session" in service.session.headers
 def test_session_token(self):
     service = Service("foo", auth=mock.MagicMock(token=FAKE_TOKEN))
     self.assertEqual(service.session.headers.get("Authorization"), FAKE_TOKEN)