def test_cron_expression_from_str_uses_given_reboot_sentinel(): """ Assert that :meth:`~crython.expression.CronExpression.new` returns a :class:`~crython.expression.CronExpression` that evaluates to a reboot expression when given a custom sentinel. """ sentinel = compat.object() expr = expression.CronExpression.from_str(expression.REBOOT_KEYWORD, reboot_sentinel=sentinel) assert expr.is_reboot is True
__all__ = ['CronExpression'] #: Number of fields for a single cron expression. FIELD_COUNT = 7 #: Set of of field names based on the order of values in the tuple as returned by `time.struct_time`. STRUCT_TIME_FIELDS = ('year', 'month', 'day', 'hour', 'minute', 'second', 'weekday') #: Reserved keyword indicating a "reboot" expression. Reboot expressions should be executed once, immediately upon #: startup. REBOOT_KEYWORD = '@reboot' #: Object indicating that the cron expression is a "@reboot". This means that there is no valid space-delimited #: value to express it and that it should just be executed "immediately" after starting. REBOOT_SENTINEL = compat.object() #: Reserved keywords that map to a specific cron expression. RESERVED_KEYWORDS = { '@yearly': '0 0 0 0 1 1 *', '@annually': '0 0 0 0 1 1 *', '@monthly': '0 0 0 0 1 * *', '@weekly': '0 0 0 0 * 0 *', '@daily': '0 0 0 * * * *', '@hourly': '0 0 * * * * *', '@minutely': '0 * * * * * *', '@secondly': '* * * * * * *' } #: Default expression string value. DEFAULT_VALUE = ' '.join(field.DEFAULT_VALUE * FIELD_COUNT)
from crython import compat, field #: Number of fields for a single cron expression. FIELD_COUNT = 7 #: Set of of field names based on the order of values in the tuple as returned by `time.struct_time`. STRUCT_TIME_FIELDS = frozenset(['year', 'month', 'day', 'hour', 'minute', 'second', 'weekday']) #: Reserved keyword indicating a "reboot" expression. Reboot expressions should be executed once, immediately upon #: startup. REBOOT_KEYWORD = '@reboot' #: Object indicating that the cron expression is a "@reboot". This means that there is no valid space-delimited #: value to express it and that it should just be executed "immediately" after starting. REBOOT_SENTINEL = compat.object() #: Reserved keywords that map to a specific cron expression. RESERVED_KEYWORDS = { '@yearly': '0 0 0 0 1 1 *', '@annually': '0 0 0 0 1 1 *', '@monthly': '0 0 0 0 1 * *', '@weekly': '0 0 0 0 * 0 *', '@daily': '0 0 0 * * * *', '@hourly': '0 0 * * * * *', '@minutely': '0 * * * * * *', '@secondly': '* * * * * * *' } #: Default expression string value. DEFAULT_VALUE = ' '.join(field.DEFAULT_VALUE * FIELD_COUNT)