summaryrefslogtreecommitdiff
path: root/reconfigure/tests/parsers/crontab_tests.py
diff options
context:
space:
mode:
authorAndrew Shadura <andrew@shadura.me>2015-08-20 15:58:26 +0200
committerAndrew Shadura <andrew@shadura.me>2015-08-20 15:58:26 +0200
commitff1408420159488a106492ccd11dd234967029b6 (patch)
tree473420cee1c5229a427ec4cafead1aa6c0a26800 /reconfigure/tests/parsers/crontab_tests.py
Imported Upstream version 0.1.29
Diffstat (limited to 'reconfigure/tests/parsers/crontab_tests.py')
-rw-r--r--reconfigure/tests/parsers/crontab_tests.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/reconfigure/tests/parsers/crontab_tests.py b/reconfigure/tests/parsers/crontab_tests.py
new file mode 100644
index 0000000..481a2f6
--- /dev/null
+++ b/reconfigure/tests/parsers/crontab_tests.py
@@ -0,0 +1,57 @@
+from reconfigure.parsers import CrontabParser
+from reconfigure.nodes import RootNode, Node, PropertyNode
+from reconfigure.tests.parsers.base_test import BaseParserTest
+
+
+class CrontabParserTest (BaseParserTest):
+ parser = CrontabParser()
+
+ source = '\n'.join(['#comment line',
+ '* * * * * date',
+ '@reboot ls -al',
+ '1 * 0 1 2 date -s',
+ 'NAME = TEST',
+ ])
+ parsed = RootNode(None,
+ children=[
+ Node('normal_task',
+ comment='comment line',
+ children=[
+ PropertyNode('minute', '*'),
+ PropertyNode('hour', '*'),
+ PropertyNode('day_of_month', '*'),
+ PropertyNode('month', '*'),
+ PropertyNode('day_of_week', '*'),
+ PropertyNode('command', 'date'),
+ ]
+ ),
+ Node('special_task',
+ children=[
+ PropertyNode('special', '@reboot'),
+ PropertyNode('command', 'ls -al'),
+ ]
+ ),
+ Node('normal_task',
+ children=[
+ PropertyNode('minute', '1'),
+ PropertyNode('hour', '*'),
+ PropertyNode('day_of_month', '0'),
+ PropertyNode('month', '1'),
+ PropertyNode('day_of_week', '2'),
+ PropertyNode('command', 'date -s'),
+ ]
+ ),
+ Node('env_setting',
+ children=[
+ PropertyNode('name', 'NAME'),
+ PropertyNode('value', 'TEST'),
+ ]
+ ),
+ ]
+ )
+# bad_source = '\n'.join(['* * * * dd', #Wrong line
+# ' = FAIL', #wrong line
+# ])
+
+
+del BaseParserTest