Skip to content

Commit

Permalink
update port to 6380
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Dec 3, 2023
1 parent 9e136ba commit 0881def
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
redis:
image: ${{ matrix.redis-image }}
ports:
- 6379:6379
- 6380:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
Expand Down
4 changes: 2 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def real_redis_version() -> Union[None, str]:
"""Returns server's version or None if server is not running"""
client = None
try:
client = redis.StrictRedis('localhost', port=6379, db=2)
client = redis.StrictRedis('localhost', port=6380, db=2)
server_version = client.info()['redis_version']
return server_version
except redis.ConnectionError:
Expand Down Expand Up @@ -80,6 +80,6 @@ def factory(db=2):
return cls(db=db, decode_responses=decode_responses, server=fake_server)
# Real
cls = getattr(redis, cls_name)
return cls('localhost', port=6379, db=db, decode_responses=decode_responses)
return cls('localhost', port=6380, db=db, decode_responses=decode_responses)

return factory
4 changes: 2 additions & 2 deletions test/test_hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

def get_redis_version() -> Tuple[int]:
try:
r = redis.StrictRedis('localhost', port=6379, db=2)
r = redis.StrictRedis('localhost', port=6380, db=2)
r.ping()
return _create_version(r.info()['redis_version'])
except redis.ConnectionError:
Expand Down Expand Up @@ -259,7 +259,7 @@ class CommonMachine(hypothesis.stateful.RuleBasedStateMachine):
def __init__(self):
super().__init__()
try:
self.real = redis.StrictRedis('localhost', port=6379, db=2)
self.real = redis.StrictRedis('localhost', port=6380, db=2)
self.real.ping()
except redis.ConnectionError:
pytest.skip('redis is not running')
Expand Down
26 changes: 13 additions & 13 deletions test/test_init_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@ def test_host_init_arg(self):

def test_from_url(self):
db = fakeredis.FakeStrictRedis.from_url(
'redis://localhost:6379/0')
'redis://localhost:6380/0')
db.set('foo', 'bar')
assert db.get('foo') == b'bar'

def test_from_url_user(self):
db = fakeredis.FakeStrictRedis.from_url(
'redis://user@localhost:6379/0')
'redis://user@localhost:6380/0')
db.set('foo', 'bar')
assert db.get('foo') == b'bar'

def test_from_url_user_password(self):
db = fakeredis.FakeStrictRedis.from_url(
'redis://user:password@localhost:6379/0')
'redis://user:password@localhost:6380/0')
db.set('foo', 'bar')
assert db.get('foo') == b'bar'

def test_from_url_with_db_arg(self):
db = fakeredis.FakeStrictRedis.from_url('redis://localhost:6379/0')
db1 = fakeredis.FakeStrictRedis.from_url('redis://localhost:6379/1')
db2 = fakeredis.FakeStrictRedis.from_url('redis://localhost:6379/', db=2)
db = fakeredis.FakeStrictRedis.from_url('redis://localhost:6380/0')
db1 = fakeredis.FakeStrictRedis.from_url('redis://localhost:6380/1')
db2 = fakeredis.FakeStrictRedis.from_url('redis://localhost:6380/', db=2)
db.set('foo', 'foo0')
db1.set('foo', 'foo1')
db2.set('foo', 'foo2')
Expand All @@ -78,17 +78,17 @@ def test_from_url_with_db_arg(self):

def test_from_url_db_value_error(self):
# In the case of ValueError, should default to 0, or be absent in redis-py 4.0
db = fakeredis.FakeStrictRedis.from_url('redis://localhost:6379/a')
db = fakeredis.FakeStrictRedis.from_url('redis://localhost:6380/a')
assert db.connection_pool.connection_kwargs.get('db', 0) == 0

def test_can_pass_through_extra_args(self):
db = fakeredis.FakeStrictRedis.from_url('redis://localhost:6379/0', decode_responses=True)
db = fakeredis.FakeStrictRedis.from_url('redis://localhost:6380/0', decode_responses=True)
db.set('foo', 'bar')
assert db.get('foo') == 'bar'

def test_can_allow_extra_args(self):
db = fakeredis.FakeStrictRedis.from_url(
'redis://localhost:6379/0',
'redis://localhost:6380/0',
socket_connect_timeout=11, socket_timeout=12, socket_keepalive=True,
socket_keepalive_options={60: 30}, socket_type=1,
retry_on_timeout=True,
Expand All @@ -103,7 +103,7 @@ def test_can_allow_extra_args(self):

# Make fallback logic match redis-py
db = fakeredis.FakeStrictRedis.from_url(
'redis://localhost:6379/0',
'redis://localhost:6380/0',
socket_connect_timeout=None, socket_timeout=30
)
fake_conn = db.connection_pool.make_connection()
Expand All @@ -113,7 +113,7 @@ def test_can_allow_extra_args(self):
def test_repr(self):
# repr is human-readable, so we only test that it doesn't crash,
# and that it contains the db number.
db = fakeredis.FakeStrictRedis.from_url('redis://localhost:6379/11')
db = fakeredis.FakeStrictRedis.from_url('redis://localhost:6380/11')
rep = repr(db)
assert 'db=11' in rep

Expand All @@ -123,8 +123,8 @@ def test_from_unix_socket(self):
assert db.get('foo') == b'bar'

def test_same_connection_params(self):
r1 = fakeredis.FakeStrictRedis.from_url('redis://localhost:6379/11')
r2 = fakeredis.FakeStrictRedis.from_url('redis://localhost:6379/11')
r1 = fakeredis.FakeStrictRedis.from_url('redis://localhost:6380/11')
r2 = fakeredis.FakeStrictRedis.from_url('redis://localhost:6380/11')
r3 = fakeredis.FakeStrictRedis(server=fakeredis.FakeServer())
r1.set('foo', 'bar')
assert r2.get('foo') == b'bar'
Expand Down
22 changes: 11 additions & 11 deletions test/test_redis_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,29 +383,29 @@ async def test_host_init_arg(self):

async def test_from_url(self):
db = aioredis.FakeRedis.from_url(
'redis://localhost:6379/0')
'redis://localhost:6380/0')
await db.set('foo', 'bar')
assert await db.get('foo') == b'bar'

async def test_from_url_user(self):
db = aioredis.FakeRedis.from_url(
'redis://user@localhost:6379/0')
'redis://user@localhost:6380/0')
await db.set('foo', 'bar')
assert await db.get('foo') == b'bar'

async def test_from_url_user_password(self):
db = aioredis.FakeRedis.from_url(
'redis://user:password@localhost:6379/0')
'redis://user:password@localhost:6380/0')
await db.set('foo', 'bar')
assert await db.get('foo') == b'bar'

async def test_from_url_with_db_arg(self):
db = aioredis.FakeRedis.from_url(
'redis://localhost:6379/0')
'redis://localhost:6380/0')
db1 = aioredis.FakeRedis.from_url(
'redis://localhost:6379/1')
'redis://localhost:6380/1')
db2 = aioredis.FakeRedis.from_url(
'redis://localhost:6379/',
'redis://localhost:6380/',
db=2)
await db.set('foo', 'foo0')
await db1.set('foo', 'foo1')
Expand All @@ -417,19 +417,19 @@ async def test_from_url_with_db_arg(self):
async def test_from_url_db_value_error(self):
# In the case of ValueError, should default to 0, or be absent in redis-py 4.0
db = aioredis.FakeRedis.from_url(
'redis://localhost:6379/a')
'redis://localhost:6380/a')
assert db.connection_pool.connection_kwargs.get('db', 0) == 0

async def test_can_pass_through_extra_args(self):
db = aioredis.FakeRedis.from_url(
'redis://localhost:6379/0',
'redis://localhost:6380/0',
decode_responses=True)
await db.set('foo', 'bar')
assert await db.get('foo') == 'bar'

async def test_can_allow_extra_args(self):
db = aioredis.FakeRedis.from_url(
'redis://localhost:6379/0',
'redis://localhost:6380/0',
socket_connect_timeout=11, socket_timeout=12, socket_keepalive=True,
socket_keepalive_options={60: 30}, socket_type=1,
retry_on_timeout=True,
Expand All @@ -444,7 +444,7 @@ async def test_can_allow_extra_args(self):

# Make fallback logic match redis-py
db = aioredis.FakeRedis.from_url(
'redis://localhost:6379/0',
'redis://localhost:6380/0',
socket_connect_timeout=None, socket_timeout=30
)
fake_conn = db.connection_pool.make_connection()
Expand All @@ -454,7 +454,7 @@ async def test_can_allow_extra_args(self):
async def test_repr(self):
# repr is human-readable, so we only test that it doesn't crash,
# and that it contains the db number.
db = aioredis.FakeRedis.from_url('redis://localhost:6379/11')
db = aioredis.FakeRedis.from_url('redis://localhost:6380/11')
rep = repr(db)
assert 'db=11' in rep

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ deps =
[docker:redis]
image = redis/redis-stack-server:7.2.0-v0
ports =
6379:6379/tcp
6380:6379/tcp
healtcheck_cmd = python -c "import socket;print(True) if 0 == socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex(('127.0.0.1',6379)) else False"

0 comments on commit 0881def

Please sign in to comment.