def test_get_config_e(self): testconfpath = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))),'conf','dummy.config') testconfig = ConfigParser.SafeConfigParser() testconfig.read(testconfpath) util.get_config(testconfpath)
body = 'init' line = '\n' count = 0 # get result from rds with aws.rdsconn(config) as rdsconn: colnames = " maker_id,data_type, to_char(data_date,'YYYY-MM-DD'), status, msg " sql = "select {0} from data_ctrl_mst where status != 'success' order by 1,2,3,4;".format(colnames) res = aws.fetch_sql(rdsconn, sql) count = len(res) rescount = '未完了の件数 : {0}\n'.format(count) log.print_log(logger,rescount) if count > 10: colnames = " status, count(*) " sql = "select {0} from data_ctrl_mst group by status order by 1;".format(colnames) res = aws.fetch_sql(rdsconn, sql) body = rescount + colnames + line + line.join(map(str, res)) except Exception as e: log.except_log(logger, e) body = str(type(e)) + line + e.message finally: if count == 0: sys.exit(0) ml = mail.kaden_mail() ml.send_message(body, '[kaden] データ更新状況', config.get('mail', 'mailfrom'), config.get('mail', 'mailto')) if __name__ == '__main__': logger = log.init_logger(False, os.path.basename(__file__)) confpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'conf', 'app.config') config = util.get_config(confpath) main()
def test_get_config(self): testconfpath = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))),'conf','app.config') testconfig = ConfigParser.SafeConfigParser() testconfig.read(testconfpath) actual = util.get_config(testconfpath) assert actual.get('app','apiurl') == testconfig.get('app','apiurl')