20 lines
766 B
Python
20 lines
766 B
Python
import sys
|
|
from pathlib import Path
|
|
import unittest
|
|
sys.path.insert(0, str(Path(__file__).parents[1] / 'scripts'))
|
|
from sync import parse_index, validate_document
|
|
|
|
class TestBSI(unittest.TestCase):
|
|
def test_index_filter(self):
|
|
self.assertEqual(parse_index(b'2016/a.json\n2017/b.json\n2026/c.json\n', 2017), ['2017/b.json','2026/c.json'])
|
|
def test_bad_index(self):
|
|
with self.assertRaises(ValueError):
|
|
parse_index(b'../../evil.json\n', 2017)
|
|
def test_doc(self):
|
|
validate_document(b'{"document":{"tracking":{"id":"WID-1","current_release_date":"2026-01-01"}}}', '2026/a.json')
|
|
with self.assertRaises(ValueError):
|
|
validate_document(b'{}', '2026/a.json')
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|