Unleash / unleash-client-python

Unleash client SDK for Python 💡💡💡
http://unleash.github.io/unleash-client-python
MIT License
84 stars 60 forks source link

ETag test failing #275

Closed Tymek closed 1 year ago

Tymek commented 1 year ago

Describe the bug ETag test in tests/unit_tests/api/test_feature.py:92 is broken.

To Reproduce Steps to reproduce the behavior:

  1. Run tests

Additional context It's skipping this test was pushed forward in time multiple times. Let's track this issue and attempts to solve it here.

yjabri commented 1 year ago

I believe the problem is the argument json={} in the responses.add(...). According to RFC 7232 - 4.1 304 Not Modified

A 304 response cannot contain a message-body; it is always terminated by the first empty line after the header field

I think that's why calling session.get in the test raises

requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(2 bytes read, -2 more expected)', IncompleteRead(2 bytes read, -2 more expected))

The two bytes being {}. I validated that removing the argument and changing the call to

responses.add(
    responses.GET, PROJECT_URL, status=304, headers={"etag": ETAG_VALUE}
)

makes the test pass.

Tymek commented 1 year ago

@yjabri If you confirmed that it will make tests pass, PRs are welcome 👍🏻 You can try tests in CI with a PR Draft

yjabri commented 1 year ago

@Tymek Does this PR look okay to you? I believe it addresses the problem raised.