def test_creds_are_pulled_from_secret(self, monkeypatch): task = RedisExecute() redis = MagicMock() monkeypatch.setattr("prefect.tasks.redis.redis_tasks.redis.Redis", redis) with set_temporary_config({"cloud.use_local_secrets": True}): with prefect.context(secrets=dict(REDIS_PASSWORD="******")): task.run(redis_cmd="GET foo") assert redis.call_args[1]["password"] == 42
def test_redis_params_passed_to_connection(self, monkeypatch): redis_params = {"custom_parameter": "value"} task = RedisExecute(redis_connection_params=redis_params) redis = MagicMock() monkeypatch.setattr("prefect.tasks.redis.redis_tasks.redis.Redis", redis) with set_temporary_config({"cloud.use_local_secrets": True}): with prefect.context(secrets=dict(REDIS_PASSWORD="******")): task.run(redis_cmd="GET foo") assert redis.call_args[1]["custom_parameter"] == "value"
def test_raises_if_command_not_provided(self): task = RedisExecute() with pytest.raises(ValueError) as exc: task.run() assert "A redis command must be specified" == str(exc.value)
def test_raises_if_command_not_provided(self): task = RedisExecute() with pytest.raises(ValueError, match="A redis command must be specified"): task.run()