dmenv 0.15.0

Simple and practical virtualenv manager for Python
Documentation
mod helpers;
use crate::helpers::TestApp;

#[test]
fn show_venv_path() {
    let test_app = TestApp::new();
    test_app.assert_run_ok(&["show:venv_path"]);
}

#[test]
fn init_works() {
    let test_app = TestApp::new();
    test_app.remove_setup_py();
    test_app.remove_setup_cfg();

    #[rustfmt::skip]
    test_app.assert_run_ok(&[
        "init", "foo",
        "--version", "0.42",
        "--author", "jane@corp.com",
    ]);

    test_app.assert_run_ok(&["lock"]);
}

#[test]
fn bump_in_lock_simple() {
    let test_app = TestApp::new();
    test_app.assert_run_ok(&["bump-in-lock", "attrs", "19.2.0"]);
    let actual = test_app.read_dev_lock();
    assert!(actual.contains("attrs==19.2.0"));
}

#[test]
fn init_does_not_overwrite_existing_setup_py() {
    let test_app = TestApp::new();
    test_app.assert_run_error(&["init", "foo"]);
    test_app.assert_setup_py();
}

#[test]
fn lock_complains_if_setup_py_does_not_exist() {
    let test_app = TestApp::new();
    test_app.remove_setup_py();
    test_app.assert_run_error(&["lock"]);
}

#[test]
fn lock_workflow() {
    let test_app = TestApp::new();
    test_app.assert_run_ok(&["lock"]);
    let lock_contents = test_app.read_dev_lock();
    assert!(lock_contents.contains("pytest=="));
    assert!(!lock_contents.contains("pkg-resources=="));
    test_app.assert_run_ok(&["show:deps"]);
    test_app.assert_run_ok(&["show:outdated"]);
    test_app.assert_run_ok(&["run", "--no-exec", "demo"]);
    test_app.assert_run_ok(&["run", "--no-exec", "pytest"]);
}

#[test]
fn production_workflow() {
    let test_app = TestApp::new();
    test_app.remove_prod_lock();
    test_app.assert_run_ok(&["--production", "lock"]);
    let lock_contents = test_app.read_prod_lock();
    assert!(!lock_contents.contains("pytest"));
    assert!(lock_contents.contains("path.py"));
    assert!(lock_contents.contains("gunicorn"));

    test_app.assert_run_ok(&["--production", "clean"]);
    test_app.assert_run_ok(&["--production", "install"]);
    test_app.assert_run_ok(&["--production", "run", "--no-exec", "demo"]);
}

#[test]
fn install_workflow_basic() {
    let test_app = TestApp::new();
    test_app.assert_run_ok(&["install"]);
    test_app.assert_run_ok(&["run", "--no-exec", "demo"]);
    test_app.assert_run_ok(&["run", "--no-exec", "pytest"]);
}

#[test]
fn install_workflow_step_by_step() {
    let test_app = TestApp::new();
    test_app.assert_run_ok(&["install", "--no-develop"]);
    test_app.assert_run_ok(&["develop"]);
    test_app.assert_run_ok(&["run", "--no-exec", "demo"]);
    test_app.assert_run_ok(&["run", "--no-exec", "pytest"]);
}

#[test]
fn run_project_script() {
    let test_app = TestApp::new();
    test_app.assert_run_ok(&["install"]);
    test_app.assert_run_ok(&["run", "--no-exec", "demo.py"]);
}

#[test]
fn install_without_lock() {
    let test_app = TestApp::new();
    test_app.remove_dev_lock();
    test_app.assert_run_error(&["install"]);
}

#[test]
fn run_without_args() {
    let test_app = TestApp::new();
    test_app.assert_run_error(&["run"]);
}

#[test]
fn run_without_virtualenv() {
    let test_app = TestApp::new();
    test_app.assert_run_error(&["run", "python"]);
}