def test_request_group_header_none(self, request):
        request.return_value.status_code = 200

        session = WrappedSession("")
        session.request("POST", FAKE_URL)

        request.assert_called_once()
        assert "X-Request-Group" in request.call_args[1]["headers"]
    def test_request_group_header_no_conflict(self, request):
        request.return_value.status_code = HttpStatusCode.Ok

        session = WrappedSession("")
        session.request("POST", FAKE_URL, headers={"foo": "bar"})

        request.assert_called_once()
        assert "X-Request-Group" in request.call_args[1]["headers"]
    def test_request_group_header_conflict(self, request):
        request.return_value.status_code = HttpStatusCode.Ok

        args = "POST", FAKE_URL
        kwargs = dict(headers={"X-Request-Group": "f00"})

        session = WrappedSession("")
        session.request(*args, **kwargs)
        request.assert_called_once_with(*args, **kwargs)  # we do nothing here
Exemple #4
0
 def test_pickling(self):
     session = WrappedSession("http://example.com", timeout=10)
     self.assertEqual(10, session.timeout)
     unpickled = pickle.loads(pickle.dumps(session))
     self.assertEqual(10, unpickled.timeout)
 def test_pickling(self):
     session = WrappedSession(FAKE_URL, timeout=10)
     assert 10 == session.timeout
     unpickled = pickle.loads(pickle.dumps(session))
     assert 10 == unpickled.timeout
 def test_pickling(self):
     session = WrappedSession(FAKE_URL, timeout=10)
     self.assertEqual(10, session.timeout)
     unpickled = pickle.loads(pickle.dumps(session))
     self.assertEqual(10, unpickled.timeout)