Exemplo n.º 1
0
    def test_get_key_value_raises_if_key_not_found(self, monkeypatch,
                                                   cloud_api):
        client = MagicMock()
        client().graphql.return_value = GraphQLResult(data=dict(key_value=[]))
        monkeypatch.setattr("prefect.backend.kv_store.Client", client)

        with pytest.raises(ValueError):
            get_key_value(key="foo")

        client.return_value.graphql.assert_called_with({
            "query": {
                'key_value(where: { key: { _eq: "foo" } })': {"value"}
            }
        })
Exemplo n.º 2
0
    def test_get_key_value_calls_client_query_correctly(
            self, monkeypatch, cloud_api):
        Client = MagicMock()
        Client().graphql.return_value = GraphQLResult(
            data=dict(key_value=[GraphQLResult({"value": "bar"})], ))
        monkeypatch.setattr("prefect.backend.kv_store.Client", Client)

        value = get_key_value(key="foo")
        Client.return_value.graphql.assert_called_with({
            "query": {
                'key_value(where: { key: { _eq: "foo" } })': {"value"}
            }
        })
        assert value == "bar"
Exemplo n.º 3
0
def get_command(key):
    """
    Get the value of a key

    \b
    Arguments:
        key         TEXT    Key to get
    """
    try:
        result = kv_store.get_key_value(key=key)
        click.secho(f"Key {key!r} has value {result!r}", fg="green")
    except Exception as exc:
        log_exception(exc)
        raise TerminalError(f"Error retrieving value for key {key!r}")
Exemplo n.º 4
0
 def test_get_key_value_raises_on_server_backend(self, server_api):
     with pytest.raises(ClientError):
         get_key_value(key="foo")