Exemplo n.º 1
0
 def test_creds_are_pulled_from_secret(self, monkeypatch):
     task = RedisGet()
     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_key="foo")
     assert redis.call_args[1]["password"] == 42
Exemplo n.º 2
0
 def test_redis_params_passed_to_connection(self, monkeypatch):
     redis_params = {"custom_parameter": "value"}
     task = RedisGet(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_key="foo")
     assert redis.call_args[1]["custom_parameter"] == "value"
Exemplo n.º 3
0
 def test_raises_key_val_not_provided(self):
     task = RedisGet()
     with pytest.raises(ValueError) as exc:
         task.run()
     assert "redis_key must be provided" == str(exc.value)
Exemplo n.º 4
0
 def test_construction(self):
     task = RedisGet()
     assert task.host == "localhost"
Exemplo n.º 5
0
 def test_raises_key_val_not_provided(self):
     task = RedisGet()
     with pytest.raises(ValueError, match="redis_key must be provided"):
         task.run()