1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2026-06-19 22:28:17 +02:00

add proc-net-igmp6 parser and tests

This commit is contained in:
Kelly Brazil
2022-09-25 18:16:54 -07:00
parent e4a40704b5
commit 5186347b48
6 changed files with 352 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
[{"index":1,"name":"lo","address":"ff020000000000000000000000000001","users":1,"group":"0000000C","reporters":0},{"index":1,"name":"lo","address":"ff010000000000000000000000000001","users":1,"group":"00000008","reporters":0},{"index":2,"name":"ens33","address":"ff0200000000000000000001ffa4e315","users":1,"group":"00000004","reporters":0},{"index":2,"name":"ens33","address":"ff020000000000000000000000000001","users":2,"group":"0000000C","reporters":0},{"index":2,"name":"ens33","address":"ff010000000000000000000000000001","users":1,"group":"00000008","reporters":0}]
+44
View File
@@ -0,0 +1,44 @@
import os
import unittest
import json
from typing import Dict
import jc.parsers.proc_net_igmp6
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase):
f_in: Dict = {}
f_json: Dict = {}
@classmethod
def setUpClass(cls):
fixtures = {
'proc_net_igmp6': (
'fixtures/linux-proc/net_igmp6',
'fixtures/linux-proc/net_igmp6.json')
}
for file, filepaths in fixtures.items():
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
cls.f_in[file] = a.read()
cls.f_json[file] = json.loads(b.read())
def test_proc_net_igmp6_nodata(self):
"""
Test 'proc_net_igmp6' with no data
"""
self.assertEqual(jc.parsers.proc_net_igmp6.parse('', quiet=True), [])
def test_proc_net_igmp6(self):
"""
Test '/proc/net/igmp6'
"""
self.assertEqual(jc.parsers.proc_net_igmp6.parse(self.f_in['proc_net_igmp6'], quiet=True),
self.f_json['proc_net_igmp6'])
if __name__ == '__main__':
unittest.main()