def test_writeShouldWriteValueToSettingsFile(self): shutil.copyfile(SAMPLE_SETTINGS_FILE, TEST_SETTINGS_FILE) general_settings = Settings(TEST_SETTINGS_FILE) new_settings = { constants.GENERAL_SECTION: { constants.SAVE_LOCATION: Path('new'), }, constants.API_SECTION: { constants.ACCESS_TOKEN: 'new', constants.ACCESS_SECRET: 'new', constants.CONSUMER_KEY: 'new', constants.CONSUMER_SECRET: 'new', }, constants.SCHEDULE_SECTION: { constants.IS_SCHEDULED: True, constants.SCHEDULE_PERIOD: DltaskScheduler.SchedulePeriods.HOURLY, constants.START_HOUR: 1, constants.START_MINUTE: 1, }, } general_settings.set(new_settings) general_settings.write() settings = Settings(TEST_SETTINGS_FILE).get() for section_name, section in new_settings.items(): for option_name, option in section.items(): assert settings[section_name][option_name] == option
def test_writeShouldWriteValueToNonExistantSettingsFile(self): assert TEST_SETTINGS_FILE.exists() == False general_settings = Settings(TEST_SETTINGS_FILE) sample_settings = Settings(SAMPLE_SETTINGS_FILE).get() general_settings.set(sample_settings) general_settings.write() assert TEST_SETTINGS_FILE.exists() == True settings = Settings(TEST_SETTINGS_FILE).get() for section_name, section in sample_settings.items(): for option_name, option in section.items(): assert settings[section_name][option_name] == option