mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
36 lines
954 B
Python
36 lines
954 B
Python
![]() |
import os
|
||
|
import unittest
|
||
|
import json
|
||
|
import jc.parsers.m3u
|
||
|
|
||
|
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/m3u-example.m3u'), 'r', encoding='utf-8') as f:
|
||
|
self.m3u_example = f.read()
|
||
|
|
||
|
# output
|
||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/m3u-example.json'), 'r', encoding='utf-8') as f:
|
||
|
self.m3u_example_json = json.loads(f.read())
|
||
|
|
||
|
|
||
|
def test_m3u_nodata(self):
|
||
|
"""
|
||
|
Test 'm3u' parser with no data
|
||
|
"""
|
||
|
self.assertEqual(jc.parsers.m3u.parse('', quiet=True), [])
|
||
|
|
||
|
def test_m3u_example(self):
|
||
|
"""
|
||
|
Test 'm3u' example file
|
||
|
"""
|
||
|
self.assertEqual(jc.parsers.m3u.parse(self.m3u_example, quiet=True), self.m3u_example_json)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
unittest.main()
|