-
-
Notifications
You must be signed in to change notification settings - Fork 445
Fixing failed test #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MehrazRumman
wants to merge
12
commits into
jazzband:master
Choose a base branch
from
MehrazRumman:fixing_failed_test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+256
−4
Open
Fixing failed test #809
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e4f7144
Fixing issue #766
MehrazRumman 3ceb08b
ruff ran
MehrazRumman 190668e
gzip fix
MehrazRumman 5e4ed9d
changelog.d updated
MehrazRumman 01c59bc
gzip tests added
MehrazRumman 6a2a57a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 616995a
tests updated
MehrazRumman 85485db
Merge branch 'fixing_failed_test' of https://github.com/MehrazRumman/…
MehrazRumman 062f2ad
tests added
MehrazRumman eff38cf
removing compressors.tests
MehrazRumman 074355d
fix cache itersize fixture
MehrazRumman 2ed5e3a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Make gzip compression deterministic by using a fixed mtime so identical inputs produce identical compressed bytes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| import threading | ||
| import time | ||
| from collections.abc import Iterable | ||
| from contextlib import suppress | ||
| from datetime import timedelta | ||
| from typing import Union, cast | ||
| from unittest.mock import patch | ||
|
|
@@ -22,11 +23,13 @@ | |
| @pytest.fixture | ||
| def patch_itersize_setting() -> Iterable[None]: | ||
| # destroy cache to force recreation with overriden settings | ||
| del caches["default"] | ||
| with suppress(AttributeError): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps this should be solved somehow different? why is it needed? which Django version introduced this error? |
||
| del caches["default"] | ||
| with override_settings(DJANGO_REDIS_SCAN_ITERSIZE=30): | ||
| yield | ||
| # destroy cache to force recreation with original settings | ||
| del caches["default"] | ||
| with suppress(AttributeError): | ||
| del caches["default"] | ||
|
|
||
|
|
||
| class TestDjangoRedisCache: | ||
|
|
@@ -871,6 +874,60 @@ def test_hexists(self, cache: RedisCache): | |
| assert cache.hexists("foo_hash5", "foo1") | ||
| assert not cache.hexists("foo_hash5", "foo") | ||
|
|
||
| def test_hget_and_hgetall(self, cache: RedisCache): | ||
| if isinstance(cache.client, ShardClient): | ||
| pytest.skip("ShardClient doesn't support get_client") | ||
| cache.hset("foo_hash6", "foo1", "bar1") | ||
| cache.hset("foo_hash6", "foo2", 2) | ||
|
|
||
| assert cache.hget("foo_hash6", "foo1") == "bar1" | ||
| assert cache.hget("foo_hash6", "foo2") == 2 | ||
| assert cache.hget("foo_hash6", "missing") is None | ||
|
|
||
| assert cache.hgetall("foo_hash6") == {"foo1": "bar1", "foo2": 2} | ||
|
|
||
| def test_hmset_and_hmget(self, cache: RedisCache): | ||
| if isinstance(cache.client, ShardClient): | ||
| pytest.skip("ShardClient doesn't support get_client") | ||
| data = {"foo1": "bar1", "foo2": 2, "foo3": 3} | ||
| assert cache.hmset("foo_hash7", data) | ||
| values = cache.hmget("foo_hash7", ["foo1", "foo2", "foo3", "foo4"]) | ||
| assert values == ["bar1", 2, 3, None] | ||
| assert cache.hmget("foo_hash7", "foo1", "foo3") == ["bar1", 3] | ||
|
|
||
| def test_hsetnx(self, cache: RedisCache): | ||
| if isinstance(cache.client, ShardClient): | ||
| pytest.skip("ShardClient doesn't support get_client") | ||
| assert cache.hsetnx("foo_hash8", "foo1", "bar1") == 1 | ||
| assert cache.hsetnx("foo_hash8", "foo1", "bar2") == 0 | ||
| assert cache.hget("foo_hash8", "foo1") == "bar1" | ||
| assert cache.hsetnx("foo_hash8", "foo2", "bar2") == 1 | ||
| assert cache.hget("foo_hash8", "foo2") == "bar2" | ||
|
|
||
| def test_hincrby_and_hincrbyfloat(self, cache: RedisCache): | ||
| if isinstance(cache.client, ShardClient): | ||
| pytest.skip("ShardClient doesn't support get_client") | ||
| cache.hset("foo_hash9", "foo1", 1) | ||
| assert cache.hincrby("foo_hash9", "foo1", 2) == 3 | ||
| assert cache.hget("foo_hash9", "foo1") == 3 | ||
|
|
||
| new_value = cache.hincrbyfloat("foo_hash9", "foo1", 0.5) | ||
| assert new_value == pytest.approx(3.5) | ||
| assert cache.hget("foo_hash9", "foo1") == pytest.approx(3.5) | ||
|
|
||
| def test_hvals_and_hstrlen(self, cache: RedisCache): | ||
| if isinstance(cache.client, ShardClient): | ||
| pytest.skip("ShardClient doesn't support get_client") | ||
| cache.hset("foo_hash10", "foo1", "bar1") | ||
| cache.hset("foo_hash10", "foo2", 2) | ||
|
|
||
| assert set(cache.hvals("foo_hash10")) == {"bar1", 2} | ||
|
|
||
| cache.hset("foo_hash10", "foo3", 12345) | ||
| assert set(cache.hvals("foo_hash10")) == {"bar1", 2, 12345} | ||
| assert cache.hstrlen("foo_hash10", "foo3") == 5 | ||
| assert cache.hstrlen("foo_hash10", "foo_missing") == 0 | ||
|
|
||
| def test_sadd(self, cache: RedisCache): | ||
| assert cache.sadd("foo", "bar") == 1 | ||
| assert cache.smembers("foo") == {"bar"} | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do not have incrbyfloat, why add it to hash commands?