def test_setShouldReplaceSettingState(self): 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, }, } app_settings = Settings(SAMPLE_SETTINGS_FILE) app_settings.set(new_settings) settings = app_settings.get() for section_name, section in new_settings.items(): for option_name, option in section.items(): assert settings[section_name][option_name] == option
class RuntimeBindings: def __init__(self, app_path): logging.info('Initializing objects') self._settings = Settings(app_path / constants.FILENAME_SETTINGS) self._history = DownloadHistory() self._retriever = TweetsRetriever_TwitterAPI(self._history, self._settings) self._scheduler = DltaskScheduler(app_path) self._abort = AbortFlag() logging.info('Finished initializing objects') def get_settings(self): return self._settings def get_save_location(self): return Path(self._settings.get()[constants.GENERAL_SECTION][ constants.SAVE_LOCATION]) def get_users(self): return readUserList(self.get_save_location() / constants.FILENAME_USERS) def get_history(self): return self._history def get_tweet_retriever(self): return self._retriever def get_scheduler(self): return self._scheduler def get_abort(self): return self._abort def download_media(self, url, savepath): downloadMedia(url, savepath)