def __init__(self, *args, **kwargs): super(InBotTestCase, self).__init__(*args, **kwargs) self.configuration = Configuration.load() if 'CI_DATABASE' in os.environ: self.configuration.database_url = Configuration._parse_database_url( os.environ['CI_DATABASE']) self.connection = DatabaseConnection(self.configuration)
def test_read_from_file(self): config = Configuration.load() self.assertEqual('bot_token:for_test', config.telegram_bot_token) self.assertEqual('postgresql+psycopg2://json:[email protected]:111/db_name', config.database_url) self.assertEqual('viers_test', config.superuser_login) self.assertEqual('socks5://test.com', config.proxy_params['proxy_url']) self.assertEqual('socks5_user', config.proxy_params['urllib3_proxy_kwargs']['username']) self.assertEqual('socks5_password', config.proxy_params['urllib3_proxy_kwargs']['password'])
def test_command_line(self): config = Configuration.load() self.assertEqual('test_token', config.telegram_bot_token) self.assertEqual('postgresql+psycopg2://a:[email protected]:1/e', config.database_url) self.assertEqual('test_user', config.superuser_login) self.assertEqual('socks5://test.com:1', config.proxy_params['proxy_url']) self.assertEqual('proxy_user', config.proxy_params['urllib3_proxy_kwargs']['username']) self.assertEqual('proxy_password', config.proxy_params['urllib3_proxy_kwargs']['password'])
def test_read_from_file(self): config = Configuration.load() self.assertEqual('bot_token:for_test', config.telegram_bot_token) self.assertEqual('socks5://test.com', config.proxy_params['proxy_url']) self.assertEqual( 'socks5_user', config.proxy_params['urllib3_proxy_kwargs']['username']) self.assertEqual( 'socks5_password', config.proxy_params['urllib3_proxy_kwargs']['password'])
def test_command_line(self): config = Configuration.load() self.assertEqual('test_token', config.telegram_bot_token) self.assertEqual('socks5://test.com:1', config.proxy_params['proxy_url']) self.assertEqual( 'proxy_user', config.proxy_params['urllib3_proxy_kwargs']['username']) self.assertEqual( 'proxy_password', config.proxy_params['urllib3_proxy_kwargs']['password'])
def _set_up(self): logging.basicConfig( format='%(asctime)s:%(name)s:%(levelname)s - %(message)s', level=logging.INFO) self.configuration = Configuration.load() self.db = DatabaseConnection(self.configuration) self.translations = Translations(APP_DIR.joinpath('i18n'), APP_DIR) self.updater = Updater(token=self.configuration.telegram_bot_token, request_kwargs=self.configuration.proxy_params) self.dispatcher = Dispatcher(self.updater, self.db, self.translations) ReportsSender.instance = ReportsSender(self.updater.bot, self.configuration)
def test_command_line_priority(self): config = Configuration.load() self.assertEqual('token_override', config.telegram_bot_token)
def _set_up(self): logging.basicConfig(format='%(asctime)s:%(name)s:%(levelname)s - %(message)s', level=logging.INFO) self.configuration = Configuration.load() self.updater = Updater(token=self.configuration.telegram_bot_token, request_kwargs=self.configuration.proxy_params) self.dispatcher = Dispatcher(self.updater)