genius-core-client 0.4.0

Genius Core Client Library. Written in Rust and using PyO3 for Python bindings.
Documentation
use cucumber::{given, then, when, World as _};
use genius_core_client::client::{Client, Protocol};
use std::env;
use tokio::runtime::Runtime;

#[derive(cucumber::World, Debug, Default)]
struct ClientWorld {
    client: Option<Client>,
}

#[given("I have the correct environment variables")]
async fn given_env_vars(_w: &mut ClientWorld) {
    let genius_db_url = env::var("GENIUS_DB_URL");
    let genius_db_port = env::var("GENIUS_DB_PORT");
    let token = env::var("GENIUS_JWT");

    assert!(genius_db_url.is_ok(), "GENIUS_DB_URL not set");
    assert!(genius_db_port.is_ok(), "GENIUS_DB_PORT not set");
    assert!(token.is_ok(), "GENIUS_JWT not set");
}

#[when("I create a new client")]
async fn when_create_client(w: &mut ClientWorld) {
    let genius_db_url = env::var("GENIUS_DB_URL").unwrap();
    let genius_db_port = env::var("GENIUS_DB_PORT").unwrap();
    let token = env::var("GENIUS_JWT").unwrap();

    let rt = Runtime::new().unwrap();
    let client_result = rt.block_on(Client::new_with_oauth2_token(
        Protocol::HTTPS,
        genius_db_url,
        genius_db_port,
        token,
        None,
    ));

    w.client = Some(client_result.unwrap());
}

#[then("the client should be created successfully")]
async fn then_client_created(w: &mut ClientWorld) {
    assert!(w.client.is_some(), "Client was not created");
}

#[tokio::main]
async fn main() {
    ClientWorld::cucumber()
        .run("tests/features/client.feature")
        .await;
}