fix: handle holiday change

fix #14
This commit is contained in:
NateScarlet
2019-07-16 22:28:44 +08:00
parent 2c1907f4da
commit dcd35fa511
2 changed files with 83 additions and 25 deletions

View File

@@ -2,11 +2,23 @@
import json
import sys
from fetch_holidays import CustomJSONEncoder, DescriptionParser
from fetch_holidays import CustomJSONEncoder, DescriptionParser, get_paper_urls, get_rules, get_paper
from .filetools import _file_path
def test_get_paper_urls():
assert get_paper_urls(2019) == [
'http://www.gov.cn/zhengce/content/2019-03/22/content_5375877.htm',
'http://www.gov.cn/zhengce/content/2018-12/06/content_5346276.htm'
]
def test_get_patch_rules():
assert(list(get_rules(get_paper('http://www.gov.cn/zhengce/content/2019-03/22/content_5375877.htm')))
== [('劳动节', '2019年5月1日至4日放假调休共4天。4月28日星期日、5月5日星期日上班。')])
def _normalize(iterable):
return sorted(json.loads(json.dumps(list(iterable), cls=CustomJSONEncoder)),
key=lambda x: x['date'])