Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
WIP Allow skipping if txredisapi is not installed?
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre committed May 10, 2022
1 parent 25698fa commit 9d4bf57
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/replication/tcp/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from synapse.replication.tcp.redis import RedisDirectTcpReplicationClientFactory
try:
import txredisapi
except ImportError:
txredisapi = None

from tests.replication._base import BaseMultiWorkerStreamTestCase
from tests.unittest import HomeserverTestCase
Expand All @@ -38,7 +41,12 @@


class RedisTestCase(HomeserverTestCase):
if txredisapi is None:
skip = "Redis extras not installed"

def test_subscribed_to_enough_redis_channels(self) -> None:
from synapse.replication.tcp.redis import RedisDirectTcpReplicationClientFactory

# The default main process is subscribed to USER_IP and all RDATA channels.
self.assertCountEqual(
RedisDirectTcpReplicationClientFactory.channels_to_subscribe_to_for_config(
Expand All @@ -52,7 +60,12 @@ def test_subscribed_to_enough_redis_channels(self) -> None:


class RedisWorkerTestCase(BaseMultiWorkerStreamTestCase):
if txredisapi is None:
skip = "Redis extras not installed"

def test_background_worker_subscribed_to_user_ip(self) -> None:
from synapse.replication.tcp.redis import RedisDirectTcpReplicationClientFactory

# The default main process is subscribed to USER_IP and all RDATA channels.
worker1 = self.make_worker_hs(
"synapse.app.generic_worker",
Expand All @@ -69,6 +82,8 @@ def test_background_worker_subscribed_to_user_ip(self) -> None:
)

def test_non_background_worker_not_subscribed_to_user_ip(self) -> None:
from synapse.replication.tcp.redis import RedisDirectTcpReplicationClientFactory

# The default main process is subscribed to USER_IP and all RDATA channels.
worker2 = self.make_worker_hs(
"synapse.app.generic_worker",
Expand Down

0 comments on commit 9d4bf57

Please sign in to comment.