def temp_dot_bonsai(): """ This fixture creates a temporary directory and writes a Config profiles to the disk. The tests that require checking parameters in these profiles should use this fixture """ temp_dir = mkdtemp('') home_dir = os.environ["HOME"] if "HOME" in os.environ else "" os.environ["HOME"] = temp_dir config = Config() config._update(profile='dev', username='******', accesskey='abcdefghijklmnopqrstuvwxyz', url='http://127.0.0.1') yield os.environ["HOME"] = home_dir rmtree(temp_dir)
def temp_dot_bonsai(): """ This fixture creates a temporary directory and writes a Config profiles to the disk. The tests that require checking parameters in these profiles should use this fixture """ temp_dir = mkdtemp() home_dir = os.environ["HOME"] if "HOME" in os.environ else "" os.environ["HOME"] = temp_dir config = Config() config._update(profile='dev', username='******', accesskey='00000000-1111-2222-3333-000000000001', url='http://127.0.0.1') yield os.environ["HOME"] = home_dir rmtree(temp_dir)
def test_config_update_creates_profile(temp_dot_bonsai): """ Tests that the update function creates a profile if it does not exist instead of throwing a NoSectionError """ config = Config(profile='FOO') config._update(url='BAR') assert config._has_section('FOO') is True
def test_config_default_url(temp_dot_bonsai): config = Config() config._update(profile='test_default_url') config.url == 'https://api.bons.ai'
def test_config_update(): config = Config() config._update(url='http://somewhere', accesskey='123', username='******') assert config.url == 'http://somewhere' assert config.accesskey == '123' assert config.username == 'bob'