1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/tests/test_crontab_u.py

41 lines
1.5 KiB
Python
Raw Normal View History

2020-02-04 14:11:34 -08:00
import os
import json
import unittest
import jc.parsers.crontab_u
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase):
def setUp(self):
# input
2020-03-04 19:40:32 -08:00
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/crontab-u.out'), 'r', encoding='utf-8') as f:
2020-02-04 14:11:34 -08:00
self.ubuntu_18_4_crontab_u = f.read()
2020-03-04 19:40:32 -08:00
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/crontab-u.out'), 'r', encoding='utf-8') as f:
2020-02-05 15:52:39 -08:00
self.centos_7_7_crontab_u = f.read()
2020-02-04 14:11:34 -08:00
# output
2020-03-04 19:40:32 -08:00
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/crontab-u.json'), 'r', encoding='utf-8') as f:
2020-02-04 14:11:34 -08:00
self.ubuntu_18_4_crontab_u_json = json.loads(f.read())
2020-03-04 19:40:32 -08:00
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/crontab-u.json'), 'r', encoding='utf-8') as f:
2020-02-05 15:52:39 -08:00
self.centos_7_7_crontab_u_json = json.loads(f.read())
2020-02-04 14:11:34 -08:00
def test_crontab_u_ubuntu_18_4(self):
"""
Test 'crontab' on Ubuntu 18.4 (has a user field)
"""
self.assertEqual(jc.parsers.crontab_u.parse(self.ubuntu_18_4_crontab_u, quiet=True), self.ubuntu_18_4_crontab_u_json)
2020-02-05 15:52:39 -08:00
def test_crontab_u_centos_7_7(self):
"""
Test 'crontab' on Centos 7.7 (has a user field)
"""
self.assertEqual(jc.parsers.crontab_u.parse(self.centos_7_7_crontab_u, quiet=True), self.centos_7_7_crontab_u_json)
2020-02-04 14:11:34 -08:00
if __name__ == '__main__':
unittest.main()