Initial Microsoft MSRC mirror
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'scripts'))
|
||||
import sync
|
||||
|
||||
class MirrorTests(unittest.TestCase):
|
||||
def test_index(self):
|
||||
self.assertEqual(len(sync.index_rows({'value': [{'ID': '2026-Nov'}]})), 1)
|
||||
with self.assertRaises(ValueError):
|
||||
sync.index_rows({'value': []})
|
||||
def test_update_and_idempotency(self):
|
||||
index = {'value': [{'ID': '2026-Nov', 'CurrentReleaseDate': '2026-11-10T00:00:00Z'}]}
|
||||
with tempfile.TemporaryDirectory() as t:
|
||||
with patch.object(sync, 'fetch', side_effect=[index, {'DocumentTitle': {'Value': 'test'}}]):
|
||||
sync.sync(Path(t), 2017, 45, False, 0)
|
||||
target = Path(t)/'data/cvrf/2026/2026-Nov.json'
|
||||
self.assertTrue(target.exists())
|
||||
with patch.object(sync, 'fetch', side_effect=[index, {'DocumentTitle': {'Value': 'test'}}]):
|
||||
sync.sync(Path(t), 2017, 45, False, 0)
|
||||
self.assertEqual(__import__('json').loads((Path(t)/'state/sync.json').read_text())['changed'], 0)
|
||||
if __name__ == '__main__': unittest.main()
|
||||
Reference in New Issue
Block a user