Exemplo n.º 1
0
def test_undecorated_function_w_param(monkeypatch, tmp_sample_dir):
    monkeypatch.setattr(sys, 'argv', [
        'python', '--entry-point', 'test_pkg.entry.plain_function_w_param',
        'some_value_for_param'
    ])

    build.main(catch_exception=False)
Exemplo n.º 2
0
def test_invalid_spec_entry_point(args, monkeypatch_session):
    monkeypatch_session.setattr(sys, 'argv', ['python'] + args)

    with pytest.raises(ValueError) as excinfo:
        build.main(catch_exception=False)

    assert 'Could not determine the entry point type' in str(excinfo.value)
Exemplo n.º 3
0
def test_invalid_function(monkeypatch):
    monkeypatch.setattr(
        sys, 'argv',
        ['python', '--entry-point', 'test_pkg.entry.invalid_function'])

    with pytest.raises(AttributeError):
        build.main(catch_exception=False)
Exemplo n.º 4
0
def test_invalid_spec_entry_point(args, monkeypatch):
    monkeypatch.setattr(sys, 'argv', ['python'] + args)

    with pytest.raises(ValueError) as excinfo:
        build.main(catch_exception=False)

    assert 'YAML file is expected' in str(excinfo.value)
Exemplo n.º 5
0
def test_invalid_entry_point_value(monkeypatch):
    monkeypatch.setattr(sys, 'argv',
                        ['python', '--entry-point', 'invalid_entry_point'])

    with pytest.raises(ValueError) as excinfo:
        build.main(catch_exception=False)

    assert 'Could not determine the entry point type' in str(excinfo.value)
Exemplo n.º 6
0
def test_build_uses_telemetry(monkeypatch, tmp_directory):
    _write_sample_conda_env()
    Path('setup.py').write_text(setup_py)

    mock = Mock()
    monkeypatch.setattr(sys, 'argv',
                        ['python', '--entry-point', 'test_pkg.entry.with_doc'])
    monkeypatch.setattr(build.telemetry, "log_api", mock)

    build.main(catch_exception=False)
    assert mock.call_count == 1
Exemplo n.º 7
0
def test_build_help_shows_docstring(capsys, monkeypatch):
    monkeypatch.setattr(
        sys, 'argv',
        ['python', '--entry-point', 'test_pkg.entry.with_doc', '--help'])

    with pytest.raises(SystemExit) as excinfo:
        build.main(catch_exception=False)

    out, _ = capsys.readouterr()

    assert not excinfo.value.code
    assert 'This is some description' in out
Exemplo n.º 8
0
def test_build(monkeypatch, tmp_sample_dir):
    monkeypatch.setattr(sys, 'argv',
                        ['python', '--entry-point', 'test_pkg.entry.with_doc'])
    build.main(catch_exception=False)
Exemplo n.º 9
0
def test_build_with_replaced_env_value(tmp_nbs, monkeypatch):
    monkeypatch.setattr(
        sys, 'argv',
        ['python', '--entry-point', 'pipeline.yaml', '--env--sample', 'True'])
    build.main(catch_exception=False)
Exemplo n.º 10
0
def test_build_command(args, tmp_nbs, monkeypatch):
    args = ['python', '--entry-point', 'pipeline.yaml'] + args
    monkeypatch.setattr(sys, 'argv', args)
    build.main(catch_exception=False)
Exemplo n.º 11
0
def test_nonexisting_module(monkeypatch):
    monkeypatch.setattr(
        sys, 'argv', ['python', '--entry-point', 'some_module.some_function'])

    with pytest.raises(ImportError):
        build.main(catch_exception=False)
Exemplo n.º 12
0
def test_w_param(monkeypatch_session, tmp_sample_dir):
    monkeypatch_session.setattr(sys, 'argv', [
        'python', '--entry-point', 'test_pkg.entry.with_param',
        'some_value_for_param'
    ])
    build.main(catch_exception=False)
Exemplo n.º 13
0
def test_replace_env_value(monkeypatch, tmp_sample_dir):
    monkeypatch.setattr(sys, 'argv', [
        'python', '--entry-point', 'test_pkg.entry.with_doc',
        '--env--path--data', '/another/path'
    ])
    build.main(catch_exception=False)
Exemplo n.º 14
0
def test_undecorated_function(monkeypatch_session, tmp_sample_dir):
    monkeypatch_session.setattr(
        sys, 'argv',
        ['python', '--entry-point', 'test_pkg.entry.plain_function'])

    build.main(catch_exception=False)
Exemplo n.º 15
0
def test_invalid_doc(monkeypatch_session, tmp_sample_dir):
    monkeypatch_session.setattr(
        sys, 'argv', ['python', '--entry-point', 'test_pkg.entry.invalid_doc'])
    build.main(catch_exception=False)
Exemplo n.º 16
0
def test_build_from_directory(arg, monkeypatch, tmp_nbs_no_yaml):
    Path('output').mkdir()
    monkeypatch.setattr(sys, 'argv', ['python', '--entry-point', arg])
    build.main(catch_exception=False)
Exemplo n.º 17
0
def test_log_enabled(monkeypatch_session, tmp_sample_dir):
    monkeypatch_session.setattr(sys, 'argv', [
        'python', '--entry-point', 'test_pkg.entry.with_doc', '--log', 'INFO'
    ])
    build.main(catch_exception=False)