1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- from synapse .replication .tcp .redis import RedisDirectTcpReplicationClientFactory
15+ try :
16+ import txredisapi
17+ except ImportError :
18+ txredisapi = None
1619
1720from tests .replication ._base import BaseMultiWorkerStreamTestCase
1821from tests .unittest import HomeserverTestCase
3841
3942
4043class RedisTestCase (HomeserverTestCase ):
44+ if txredisapi is None :
45+ skip = "Redis extras not installed"
46+
4147 def test_subscribed_to_enough_redis_channels (self ) -> None :
48+ from synapse .replication .tcp .redis import RedisDirectTcpReplicationClientFactory
49+
4250 # The default main process is subscribed to USER_IP and all RDATA channels.
4351 self .assertCountEqual (
4452 RedisDirectTcpReplicationClientFactory .channels_to_subscribe_to_for_config (
@@ -52,7 +60,12 @@ def test_subscribed_to_enough_redis_channels(self) -> None:
5260
5361
5462class RedisWorkerTestCase (BaseMultiWorkerStreamTestCase ):
63+ if txredisapi is None :
64+ skip = "Redis extras not installed"
65+
5566 def test_background_worker_subscribed_to_user_ip (self ) -> None :
67+ from synapse .replication .tcp .redis import RedisDirectTcpReplicationClientFactory
68+
5669 # The default main process is subscribed to USER_IP and all RDATA channels.
5770 worker1 = self .make_worker_hs (
5871 "synapse.app.generic_worker" ,
@@ -69,6 +82,8 @@ def test_background_worker_subscribed_to_user_ip(self) -> None:
6982 )
7083
7184 def test_non_background_worker_not_subscribed_to_user_ip (self ) -> None :
85+ from synapse .replication .tcp .redis import RedisDirectTcpReplicationClientFactory
86+
7287 # The default main process is subscribed to USER_IP and all RDATA channels.
7388 worker2 = self .make_worker_hs (
7489 "synapse.app.generic_worker" ,
0 commit comments