def test_add_command(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.add_command,
                       project_ops.add_command)

    params = dict(args=(), kwargs=dict())

    def mock_add_command(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.add_command',
                        mock_add_command)

    p = api.AnacondaProject()

    kwargs = dict(project=43,
                  command_type='bokeh_app',
                  name='name',
                  command='file.py',
                  env_spec_name='foo',
                  supports_http_options=True)
    result = p.add_command(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
def test_prepare_project_browser(monkeypatch):
    from anaconda_project.prepare import prepare_with_browser_ui
    _verify_args_match(api.AnacondaProject.prepare_project_browser,
                       prepare_with_browser_ui,
                       ignored=['self', 'keep_going_until_success'])

    params = dict(args=(), kwargs=dict())

    def mock_prepare_with_browser_ui(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.prepare.prepare_with_browser_ui',
                        mock_prepare_with_browser_ui)
    p = api.AnacondaProject()
    kwargs = dict(project=43,
                  environ=57,
                  env_spec_name='someenv',
                  command_name='foo',
                  command=1234,
                  extra_command_args=['1', '2'],
                  io_loop=156,
                  show_url=8909)
    result = p.prepare_project_browser(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
def test_update_command(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.update_command,
                       project_ops.update_command)

    params = dict(args=(), kwargs=dict())

    def mock_update_command(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.update_command',
                        mock_update_command)

    p = api.AnacondaProject()

    kwargs = dict(project=43,
                  command_type='bokeh_app',
                  name='name',
                  command='file.py',
                  new_name='foo')
    result = p.update_command(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
def test_add_download(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.add_download,
                       project_ops.add_download)

    params = dict(args=(), kwargs=dict())

    def mock_add_download(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.add_download',
                        mock_add_download)

    p = api.AnacondaProject()
    kwargs = dict(project=43,
                  env_var='boo',
                  url='baz',
                  filename="fname",
                  hash_algorithm="md5",
                  hash_value="foo")
    result = p.add_download(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #5
0
def test_load_project(monkeypatch):
    from anaconda_project.project import Project
    _verify_args_match(api.AnacondaProject.load_project, Project.__init__, ignored=['self', 'plugin_registry'])

    class MockProject(object):
        def __init__(self, *args, **kwargs):
            self.kwargs = kwargs

    monkeypatch.setattr('anaconda_project.project.Project', MockProject)
    p = api.AnacondaProject()
    kwargs = dict(directory_path='foo', frontend=37)
    project = p.load_project(**kwargs)
    assert kwargs == project.kwargs
Exemple #6
0
def test_create_project(monkeypatch):
    params = dict(args=(), kwargs=dict())

    def mock_create_project(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.create', mock_create_project)

    p = api.AnacondaProject()
    kwargs = dict(directory_path=1, make_directory=2, name='foo', icon='bar', description='blah')
    result = p.create_project(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
def test_unprepare(monkeypatch):
    from anaconda_project.prepare import unprepare
    _verify_args_match(api.AnacondaProject.unprepare, unprepare)

    params = dict(args=(), kwargs=dict())

    def mock_unprepare(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.prepare.unprepare', mock_unprepare)
    p = api.AnacondaProject()
    kwargs = dict(project=43, prepare_result=44, whitelist=45)
    result = p.unprepare(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #8
0
def test_unlock(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.unlock, project_ops.unlock)

    params = dict(args=(), kwargs=dict())

    def mock_unlock(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.unlock', mock_unlock)

    p = api.AnacondaProject()
    kwargs = dict(project=43, env_spec_name='foo')
    result = p.unlock(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #9
0
def test_unset_variables(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.unset_variables, project_ops.unset_variables)

    params = dict(args=(), kwargs=dict())

    def mock_unset_variables(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.unset_variables', mock_unset_variables)

    p = api.AnacondaProject()
    kwargs = dict(project=43, env_spec_name='boo', vars_to_unset=45, prepare_result=57)
    result = p.unset_variables(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #10
0
def test_unarchive(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.unarchive, project_ops.unarchive)

    params = dict(args=(), kwargs=dict())

    def mock_unarchive(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.unarchive', mock_unarchive)

    p = api.AnacondaProject()
    kwargs = dict(filename=43, project_dir=123, parent_dir=456, frontend=789)
    result = p.unarchive(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #11
0
def test_remove_service(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.remove_service, project_ops.remove_service)

    params = dict(args=(), kwargs=dict())

    def mock_remove_service(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.remove_service', mock_remove_service)

    p = api.AnacondaProject()
    kwargs = dict(project=43, env_spec_name=578, prepare_result=123, variable_name='xyz')
    result = p.remove_service(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #12
0
def test_remove_packages(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.remove_packages, project_ops.remove_packages)

    params = dict(args=(), kwargs=dict())

    def mock_remove_packages(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.remove_packages', mock_remove_packages)

    p = api.AnacondaProject()
    kwargs = dict(project=43, env_spec_name='foo', packages=['a'])
    result = p.remove_packages(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #13
0
def test_export_env_spec(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.export_env_spec, project_ops.export_env_spec)

    params = dict(args=(), kwargs=dict())

    def mock_export_env_spec(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.export_env_spec', mock_export_env_spec)

    p = api.AnacondaProject()
    kwargs = dict(project=43, name='foo', filename='bar')
    result = p.export_env_spec(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #14
0
def test_add_env_spec(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.add_env_spec, project_ops.add_env_spec)

    params = dict(args=(), kwargs=dict())

    def mock_add_env_spec(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.add_env_spec', mock_add_env_spec)

    p = api.AnacondaProject()
    kwargs = dict(project=43, name='foo', packages=['a'], channels=['b'])
    result = p.add_env_spec(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #15
0
def test_remove_download(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.remove_download, project_ops.remove_download)

    params = dict(args=(), kwargs=dict())

    def mock_remove_download(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.remove_download', mock_remove_download)

    p = api.AnacondaProject()
    kwargs = dict(project=43, env_spec_name="blah", prepare_result='winnebago', env_var='boo')
    result = p.remove_download(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #16
0
def test_upload(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.upload, project_ops.upload)

    params = dict(args=(), kwargs=dict())

    def mock_upload(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.upload', mock_upload)

    p = api.AnacondaProject()
    kwargs = dict(project=43, site=123, token=456, username=789, log_level='LOTS')
    result = p.upload(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #17
0
def test_set_properties(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.set_properties, project_ops.set_properties)

    params = dict(args=(), kwargs=dict())

    def mock_set_properties(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.set_properties', mock_set_properties)

    p = api.AnacondaProject()
    kwargs = dict(project=43, name='foo', icon='bar', description='blah')
    result = p.set_properties(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
def test_archive(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.archive, project_ops.archive)

    params = dict(args=(), kwargs=dict())

    def mock_archive(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.archive', mock_archive)

    p = api.AnacondaProject()
    kwargs = dict(project=43, filename=123)
    result = p.archive(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
def test_clean(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.clean, project_ops.clean)

    params = dict(args=(), kwargs=dict())

    def mock_clean(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.clean', mock_clean)

    p = api.AnacondaProject()
    kwargs = dict(project=43, prepare_result=123)
    result = p.clean(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
def _test_prepare_without_interaction(monkeypatch, api_method, provide_mode):
    from anaconda_project.prepare import prepare_without_interaction
    _verify_args_match(getattr(api.AnacondaProject, api_method),
                       prepare_without_interaction,
                       ignored=['self', 'mode', 'provide_whitelist'])

    params = _monkeypatch_prepare_without_interaction(monkeypatch)
    p = api.AnacondaProject()
    kwargs = dict(project=43,
                  environ=57,
                  env_spec_name='someenv',
                  command_name='foo',
                  command=1234,
                  extra_command_args=['1', '2'])
    result = getattr(p, api_method)(**kwargs)
    assert 42 == result
    assert params['kwargs']['mode'] == provide_mode
    del params['kwargs']['mode']
    assert kwargs == params['kwargs']
Exemple #21
0
def test_add_platforms(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.add_platforms, project_ops.add_platforms)

    params = dict(args=(), kwargs=dict())

    def mock_add_platforms(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.add_platforms', mock_add_platforms)

    p = api.AnacondaProject()

    kwargs = dict(project=43, env_spec_name='name', platforms=[47])
    result = p.add_platforms(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
Exemple #22
0
def test_remove_command(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.remove_command, project_ops.remove_command)

    params = dict(args=(), kwargs=dict())

    def mock_remove_command(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.remove_command', mock_remove_command)

    p = api.AnacondaProject()

    kwargs = dict(project=43, name='name')
    result = p.remove_command(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
def test_add_service(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.add_service,
                       project_ops.add_service)

    params = dict(args=(), kwargs=dict())

    def mock_add_service(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.add_service',
                        mock_add_service)

    p = api.AnacondaProject()
    kwargs = dict(project=43, service_type='abc', variable_name='xyz')
    result = p.add_service(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']
def test_add_variables(monkeypatch):
    import anaconda_project.project_ops as project_ops
    _verify_args_match(api.AnacondaProject.add_variables,
                       project_ops.add_variables)

    params = dict(args=(), kwargs=dict())

    def mock_add_variables(*args, **kwargs):
        params['args'] = args
        params['kwargs'] = kwargs
        return 42

    monkeypatch.setattr('anaconda_project.project_ops.add_variables',
                        mock_add_variables)

    p = api.AnacondaProject()
    kwargs = dict(project=43, vars_to_add=45, defaults=12345)
    result = p.add_variables(**kwargs)
    assert 42 == result
    assert kwargs == params['kwargs']