Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit d37bb21

Browse files
changing unit tests to account for defaults in redis flags redis/redis-py#1499 * This does not include the changes in tests/test_pubsub.py because we do not implement threading. Signed-off-by: Andrew-Chen-Wang <[email protected]>
1 parent 38a023f commit d37bb21

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

tests/test_commands.py

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,24 @@ def teardown():
118118

119119
# test enabled=False
120120
assert await r.acl_setuser(username, enabled=False, reset=True)
121-
assert await r.acl_getuser(username) == {
122-
"categories": ["-@all"],
123-
"commands": [],
124-
"channels": [b"*"],
125-
"enabled": False,
126-
"flags": ["off", "allchannels", "sanitize-payload"],
127-
"keys": [],
128-
"passwords": [],
129-
}
121+
acl = await r.acl_getuser(username)
122+
assert acl["categories"] == ["-@all"]
123+
assert acl["commands"] == []
124+
assert acl["keys"] == []
125+
assert acl["passwords"] == []
126+
assert "off" in acl["flags"]
127+
assert acl["enabled"] is False
130128

131129
# test nopass=True
132130
assert await r.acl_setuser(username, enabled=True, reset=True, nopass=True)
133-
assert await r.acl_getuser(username) == {
134-
"categories": ["-@all"],
135-
"commands": [],
136-
"channels": [b"*"],
137-
"enabled": True,
138-
"flags": ["on", "allchannels", "nopass", "sanitize-payload"],
139-
"keys": [],
140-
"passwords": [],
141-
}
131+
acl = await r.acl_getuser(username)
132+
assert acl["categories"] == ["-@all"]
133+
assert acl["commands"] == []
134+
assert acl["keys"] == []
135+
assert acl["passwords"] == []
136+
assert "on" in acl["flags"]
137+
assert "nopass" in acl["flags"]
138+
assert acl["enabled"] is True
142139

143140
# test all args
144141
assert await r.acl_setuser(
@@ -155,7 +152,7 @@ def teardown():
155152
assert set(acl["commands"]) == {"+get", "+mget", "-hset"}
156153
assert acl["enabled"] is True
157154
assert acl["channels"] == [b"*"]
158-
assert acl["flags"] == ["on", "allchannels", "sanitize-payload"]
155+
assert "on" in acl["flags"]
159156
assert set(acl["keys"]) == {b"cache:*", b"objects:*"}
160157
assert len(acl["passwords"]) == 2
161158

@@ -182,7 +179,7 @@ def teardown():
182179
assert set(acl["commands"]) == {"+get", "+mget"}
183180
assert acl["enabled"] is True
184181
assert acl["channels"] == [b"*"]
185-
assert acl["flags"] == ["on", "allchannels", "sanitize-payload"]
182+
assert "on" in acl["flags"]
186183
assert set(acl["keys"]) == {b"cache:*", b"objects:*"}
187184
assert len(acl["passwords"]) == 2
188185

@@ -233,7 +230,7 @@ def teardown():
233230

234231
assert await r.acl_setuser(username, enabled=False, reset=True)
235232
users = await r.acl_list()
236-
assert "user %s off sanitize-payload &* -@all" % username in users
233+
assert len(users) == 2
237234

238235
@skip_if_server_version_lt(REDIS_6_VERSION)
239236
async def test_acl_log(self, r: aioredis.Redis, request, event_loop, create_redis):

0 commit comments

Comments
 (0)