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

61 lines
1.6 KiB
Python
Raw Normal View History

import os
import unittest
import json
from typing import Dict
from jc.parsers.pkg_index_alpine import parse
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class Apkindex(unittest.TestCase):
f_in: Dict = {}
f_json: Dict = {}
@classmethod
def setUpClass(cls):
fixtures = {
2023-12-04 14:01:30 -08:00
'normal': (
'fixtures/generic/pkg-index-alpine.out',
'fixtures/generic/pkg-index-alpine.json'),
2023-12-04 14:01:30 -08:00
'raw': (
'fixtures/generic/pkg-index-alpine.out',
'fixtures/generic/pkg-index-alpine-raw.json')
}
for file, filepaths in fixtures.items():
2023-12-04 14:01:30 -08:00
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())
2023-12-04 14:01:30 -08:00
def test_pkg_index_alpine_nodata(self):
2023-12-04 14:01:30 -08:00
"""
Test 'pkg-index-alpine' with no data
2023-12-04 14:01:30 -08:00
"""
self.assertEqual(parse('', quiet=True), [])
def test_pkg_index_alpine(self):
"""
Test 'pkg-index-alpine' normal output
"""
2023-12-04 14:01:30 -08:00
self.assertEqual(
parse(self.f_in['normal'], quiet=True),
self.f_json['normal']
)
def test_pkg_index_alpine_raw(self):
2023-12-04 14:01:30 -08:00
"""
Test 'pkg-index-alpine' raw output
2023-12-04 14:01:30 -08:00
"""
self.assertEqual(
parse(self.f_in['raw'], quiet=True, raw=True),
self.f_json['raw']
)
if __name__ == "__main__":
unittest.main()