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

36 lines
1.2 KiB
Python
Raw Normal View History

2022-04-22 16:25:45 -07:00
import os
import unittest
import json
import jc.parsers.update_alt_gs
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase):
def setUp(self):
# input
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/update-alternatives-get-selections.out'), 'r', encoding='utf-8') as f:
self.update_alternatives_get_selections = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/update-alternatives-get-selections.json'), 'r', encoding='utf-8') as f:
self.update_alternatives_get_selections_json = json.loads(f.read())
def test_update_alt_gs_nodata(self):
"""
Test 'update-alternatives --get-selections' with no data
"""
self.assertEqual(jc.parsers.update_alt_gs.parse('', quiet=True), [])
def test_update_alt_gs(self):
"""
Test 'update-alternatives --get-selections'
"""
self.assertEqual(jc.parsers.update_alt_gs.parse(self.update_alternatives_get_selections, quiet=True), self.update_alternatives_get_selections_json)
if __name__ == '__main__':
unittest.main()