Esempio n. 1
0
def test_initialize_root_good_path(set_root, get_root):
    get_root.return_value = ''

    # good path in config uses that
    config = copy_default_config()
    config['core'] = '~'
    initialize_root(config)
    assert set_root.called
    set_root.assert_called_with(os.path.expanduser('~'))
Esempio n. 2
0
def test_initialize_root_env_var(set_root, get_root):
    get_root.return_value = ''

    ddev_env = '/tmp'
    with mock.patch.dict(os.environ, {'DDEV_ROOT': ddev_env}):
        config = copy_default_config()
        initialize_root(config)
        assert set_root.called
        set_root.assert_called_with(os.path.expanduser(ddev_env))
Esempio n. 3
0
def test_initialize_root_bad_path(set_root, get_root):
    get_root.return_value = ''

    # bad path in config results in cwd
    config = copy_default_config()
    config['core'] = '/path/does/not/exist'
    initialize_root(config)
    assert set_root.called
    set_root.assert_called_with(os.getcwd())
Esempio n. 4
0
def test_complete_set_root_here(set_root, get_root):
    get_root.return_value = ''

    with mock.patch('datadog_checks.dev.tooling.utils.load_config') as load_config:
        config = copy_default_config()
        load_config.return_value = config

        args = ['-x']
        complete_set_root(args)
        assert set_root.called
        set_root.assert_called_with(os.getcwd())
Esempio n. 5
0
def test_complete_set_root_no_args(set_root, get_root):
    get_root.return_value = ''

    with mock.patch('datadog_checks.dev.tooling.utils.load_config') as load_config:
        config = copy_default_config()
        config['core'] = '/tmp'  # ensure we choose a dir that exists
        load_config.return_value = config

        args = []
        complete_set_root(args)
        assert set_root.called
        set_root.assert_called_with(config['core'])