def test_delete_active(): set_up() Create.run(mock_options_4) assert settings.get('active') == 'test' Delete.run(mock_options_2) assert settings.get('active') is None tear_down()
def test_append(): set_up() os.mkdir('test_append') settings['append'] = {} Append.run(mock_options) shutil.rmtree('test_append', ignore_errors=True) tear_down()
def test_list_names_only(): set_up() Create.run(mock_options) Create.run(mock_options_1) Create.run(mock_options_2) List.run({}) tear_down()
def test_create(): set_up() Create.run(mock_options) path = os.path.join(settings.get('path'), 'test') assert os.path.isdir(path) assert os.path.isfile(os.path.join(path, 'ipython_config.py')) tear_down()
def test_invalid_profile(): set_up() settings.update({ 'active': 'test' }).save() Active.run({}) tear_down()
def test_append_project_exists(): set_up() os.mkdir('test_append') settings['append'] = { 'test': 'test_append' } Append.run(mock_options) shutil.rmtree('test_append', ignore_errors=True) tear_down()
def test_shell_profile_none(monkeypatch): mock(monkeypatch) set_up() settings.update({ 'append': { 'test': None } }).save() Shell.run(mock_options_2) tear_down()
def test_check_dirs(): set_up() Create.run(mock_options) path = join(settings.get('path'), 'test') profile_dir = IProfileDir.find_profile_dir(path) shutil.rmtree(profile_dir.startup_dir, ignore_errors=True) profile_dir.check_dirs() assert isfile(join(profile_dir.startup_dir, '00_config.ipy')) assert isfile(join(profile_dir.startup_dir, '01_scripts.py')) tear_down()
def test_gitignore(): set_up() gitignore = GitIgnore.callback(_autorun=False) gitignore.run() filepath = os.path.join(settings.get('path'), '.gitignore') assert os.path.isfile(filepath) with open(filepath, 'r') as f: assert f.read() == '\n'.join(gitignore.content) gitignore.run() tear_down()
def test_shell(monkeypatch): mock(monkeypatch) set_up() settings.update({ 'path': 'append_test' }).save() Create.run(mock_options) settings.update({ 'path': 'iprofiles' }).save() Shell.run(mock_options) Shell.run(mock_options_2) tear_down()
def test_icommand_list_profiles(): set_up() settings.update({ 'path': 'append_test' }).save() Create.run(mock_options) settings.update({ 'path': 'iprofiles' }).save() cmd = ICommand(_autorun=False) cmd.settings = settings cmd.list_profiles('iprofiles') tear_down()
def test_delete(): set_up() Create.run(mock_options) settings.update({ 'path': 'append_test' }).save() Create.run(mock_options) settings.update({ 'path': 'iprofiles' }).save() Delete.run(mock_options) assert not os.path.isdir(os.path.join(settings.get('path'), 'test')) tear_down()
def test_config_list_or_dict(): set_up() Config.run(mock_options_1) assert isinstance(settings.get('test_name'), list) assert len(settings.get('test_name')) == 1 assert settings.get('test_name')[0] == 'test_value' Config.run(mock_options_2) assert isinstance(settings.get('test_name'), dict) assert 'test_value' in settings.get('test_name') assert settings.get('test_name').get('test_value') == 0 tear_down()
def test_shell_active(monkeypatch): mock(monkeypatch) set_up() Create.run(mock_options_create) Shell.run(mock_options_1) settings.update({ 'path': 'append_test' }).save() Create.run(mock_options_create) settings.update({ 'path': 'iprofiles' }).save() Activate.run(mock_options_2) Shell.run(mock_options_1) tear_down()
def test_active(): set_up() Create.run(mock_options) settings.update({ 'path': 'append_test' }).save() Create.run(mock_options) settings.update({ 'path': 'iprofiles' }).save() Activate.run(mock_options) Active.run({}) Activate.run(mock_options_2) Active.run({}) tear_down()
def test_invalid_profile(): set_up() Create.run(mock_options) Create.run(mock_options) tear_down()
def test_config(): set_up() Config.run(mock_options) assert settings.get('test_name') == 'test_value' tear_down()
def test_yamlordereddict_open(): set_up() settings.base_section = None settings.open() tear_down()
def test_yamlordereddict_pop(): set_up() path = settings.get('path') assert os.path.abspath(os.path.expanduser(settings.pop('path'))) == path tear_down()
def test_append_invalid_name(): set_up() Append.run(mock_options_1) tear_down()
def test_append_invalid_path(): set_up() Append.run(mock_options_2) tear_down()
def test_shell_other_project_profile(monkeypatch): mock(monkeypatch) set_up() Shell.run(mock_options) tear_down()
def test_invalid_name(): set_up() Create.run(mock_options_1) assert not os.listdir(settings.get('path')) tear_down()
def test_list_no_profiles(): set_up() List.run({}) tear_down()
def test_list_active_profile(): set_up() Create.run(mock_options_3) List.run({}) tear_down()
def test_activate(): set_up() Create.run(mock_options) Activate.run(mock_options) assert settings.get('active') == 'test' tear_down()
def test_pop_invalid_name(): set_up() Pop.run(mock_options_1) tear_down()
def test_pop_project_exists(): set_up() Pop.run(mock_options_2) tear_down()
def test_invalid_profile(): set_up() Activate.run(mock_options) assert settings.get('active') is None tear_down()
def test_shell_invalid_profile(monkeypatch): mock(monkeypatch) set_up() Shell.run(mock_options) tear_down()