1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-23 00:29:59 +02:00
Files
jc/tests/test_apkindex.py

61 lines
1.5 KiB
Python
Raw Normal View History

import os
import unittest
import json
from typing import Dict
from jc.parsers.apkindex 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/apkindex',
'fixtures/generic/apkindex.json'),
'raw': (
'fixtures/generic/apkindex',
'fixtures/generic/apkindex.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_apkindex_nodata(self):
"""
Test 'apkindex' with no data
"""
self.assertEqual(parse('', quiet=True), [])
def test_apkindex(self):
"""
2023-12-04 14:01:30 -08:00
Test 'apkindex' 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_apkindex_raw(self):
"""
Test 'apkindex' raw output
"""
self.assertEqual(
parse(self.f_in['raw'], quiet=True, raw=True),
self.f_json['raw']
)
if __name__ == "__main__":
unittest.main()