1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/tests/test_efibootmgr.py
yaofei zheng 5ee2eda83e add efibootmgr parser (#528)
* More nsd fixes (#523)

* Update nsd_control.py

support catz output

* Update nsd_control.py

fix parsing of catz zones

* add testdata

add corresponding catz testdata

* Revert "More nsd fixes" (#526)

* add efibootmgr parser

* add efibootmgr completions

* Multiple fixes on jc/parsers/efibootmgr.py

1. Update schema in comments.
1. Add an example.
1. Use clean and clear sub string finding sytax.
1. Wrap schema in an object.
1. Make variable scope as small as possible.

* add tests for efibootmgr

* Update jc/parsers/efibootmgr.py

Update example using `--pretty` for output.

Co-authored-by: Muescha <184316+muescha@users.noreply.github.com>

* jc/parsers/efibootmgr multiple changes

1. convert all keys to "snake_case"
2. add "mirrored_percentage_above_4g" and "mirror_memory_below_4gb"
3. move conversion (from string to other types) to "_process"

---------

Co-authored-by: pettai <pettai@sunet.se>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
Co-authored-by: Muescha <184316+muescha@users.noreply.github.com>
2024-02-06 01:54:31 +00:00

34 lines
1.0 KiB
Python

import os
import json
import unittest
import jc.parsers.efibootmgr
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase):
# input
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/opensuse-leap-15.5/efibootmgr.out'), 'r', encoding='utf-8') as f:
opensuse_leap_15_5_efibootmgr = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/opensuse-leap-15.5/efibootmgr.json'), 'r', encoding='utf-8') as f:
opensuse_leap_15_5_efibootmgr_json = json.loads(f.read())
def test_efibootmgr_nodata(self):
"""
Test 'efibootmgr' with no data
"""
self.assertEqual(jc.parsers.efibootmgr.parse('', quiet=True), [])
def test_efibootmgr_opensuse_leap_15_5(self):
"""
Test 'efibootmgr' on Opensuse Leap 15.5
"""
self.assertEqual(jc.parsers.efibootmgr.parse(self.opensuse_leap_15_5_efibootmgr, quiet=True), self.opensuse_leap_15_5_efibootmgr_json)
if __name__ == '__main__':
unittest.main()