Пример #1
0
def test_setup_logger_default():
    from dhis2 import logger, setup_logger
    setup_logger()
    logger.info("info")
    logger.warning("warn")
    logger.debug("debug")
    logger.error("error")
Пример #2
0
def test_setup_logger_to_file():
    from dhis2 import logger, setup_logger

    filename = os.path.join(tempfile.gettempdir(), 'logfile.log')

    setup_logger(logfile=filename)
    logger.info("info")
    logger.warning("warn")
    logger.debug("debug")
    logger.error("error")

    assert os.path.isfile(filename)
Пример #3
0
def check_opening_date(org_unit):
    ou_name = org_unit["name"]
    ou_uid = org_unit["id"]
    ou_opening_date = org_unit["openingDate"][:-13]

    # parse the opening date to a Python date
    opening_date = datetime.strptime(ou_opening_date, "%Y-%m-%d")

    msg = "Organisation Unit '{}' ({}) was opened {} 1990-01-01 on {}"

    # compare date and print message
    if opening_date > datetime(year=1990, month=1, day=1):
        logger.warn(msg.format(ou_name, ou_uid, "AFTER", ou_opening_date))
    else:
        logger.debug(msg.format(ou_name, ou_uid, "BEFORE", ou_opening_date))