diff --git a/.circleci/config.yml b/.circleci/config.yml index b4c0d41..dbba493 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,10 +12,7 @@ orbs: workflows: build-test-publish: jobs: - - python/test: - pkg-manager: poetry - test-tool: pytest - version: "3.9" + - test: filters: tags: only: /.*/ @@ -29,29 +26,24 @@ workflows: only: /^v.*/ jobs: - # test: - # docker: - # - image: cimg/python:3.9 - # steps: - # - checkout - # # - run: sed -e '41,45d' -i pyproject.toml - # - restore_cache: - # keys: - # - venv-cache-{{ checksum "poetry.lock" }} - # - run: - # name: Poetry install - # command: | - # poetry config virtualenvs.in-project true - # poetry install -v - # - save_cache: - # paths: - # - .venv - # key: venv-cache-{{ checksum "poetry.lock" }} - # - run: - # name: pytest - # command: poetry run pytest --junitxml=test-results/junit.xml - # - store_test_results: - # path: test-results + test: + docker: + - image: cimg/python:3.9 + steps: + - checkout + # - run: sed -e '41,45d' -i pyproject.toml + - python/install-packages: + pkg-manager: poetry + - run: + name: Coverage test + command: poetry run coverage run -m pytest --junitxml=test-results/junit.xml + - store_test_results: + path: test-results + - run: + name: Collect coverage + command: coverage html --include='src/*' + - store_artifacts: + path: htmlcov build-publish: docker: - image: cimg/python:3.9 diff --git a/README.md b/README.md index 5b389dc..153af69 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![pypi](https://badgen.net/pypi/v/nonebot-hk-reporter)](https://pypi.org/project/nonebot-hk-reporter/) -[![felinae98](https://circleci.com/gh/felinae98/nonebot-hk-reporter.svg?style=svg)](https://circleci.com/gh/felinae98/nonebot-hk-reporter) +[![felinae98](https://circleci.com/gh/felinae98/nonebot-hk-reporter.svg?style=shield)](https://circleci.com/gh/felinae98/nonebot-hk-reporter) [![qq group](https://img.shields.io/badge/QQ%E7%BE%A4-868610060-orange )](https://qm.qq.com/cgi-bin/qm/qr?k=pXYMGB_e8b6so3QTqgeV6lkKDtEeYE4f&jump_from=webapi) diff --git a/src/plugins/nonebot_hk_reporter/platform/weibo.py b/src/plugins/nonebot_hk_reporter/platform/weibo.py index 33af1c2..a084a23 100644 --- a/src/plugins/nonebot_hk_reporter/platform/weibo.py +++ b/src/plugins/nonebot_hk_reporter/platform/weibo.py @@ -62,11 +62,12 @@ class Weibo(Platform): def get_tags(self, raw_post: RawPost) -> Optional[list[Tag]]: "Return Tag list of given RawPost" text = raw_post['mblog']['text'] + soup = bs(text, 'html.parser') return list(map( lambda x: x[1:-1], filter( lambda s: s[0] == '#' and s[-1] == '#', - map(lambda x:x.text, text.find_all('span', class_='surl-text')) + map(lambda x:x.text, soup.find_all('span', class_='surl-text')) ) )) diff --git a/tests/platforms/test_weibo.py b/tests/platforms/test_weibo.py index df2f588..7ac6f2a 100644 --- a/tests/platforms/test_weibo.py +++ b/tests/platforms/test_weibo.py @@ -74,5 +74,6 @@ async def test_parse_long(weibo): assert(not '全文' in post.text) assert(detail_router.called) -def text_tag(weibo, weibo_ak_list_1): - assert(weibo.get_tags(weibo_ak_list_1) == ['明日方舟', '音律联觉']) +def test_tag(weibo, weibo_ak_list_1): + raw_post = weibo_ak_list_1['data']['cards'][0] + assert(weibo.get_tags(raw_post) == ['明日方舟', '音律联觉'])