From 8592a4f6a978f58f90306acda46d7d7f4fb7c266 Mon Sep 17 00:00:00 2001 From: Ajinkya Udgirkar Date: Wed, 15 Feb 2023 18:16:00 +0530 Subject: [PATCH] Add full coverage to meta_video_links rule (#3036) Co-authored-by: Ajinkya Udgirkar --- .github/workflows/tox.yml | 2 +- test/rules/test_meta_video_links.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 94d19b4e85..c481c35364 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -70,7 +70,7 @@ jobs: WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:GITHUB_STEP_SUMMARY # Number of expected test passes, safety measure for accidental skip of # tests. Update value if you add/remove tests. - PYTEST_REQPASS: 795 + PYTEST_REQPASS: 796 steps: - name: Activate WSL1 diff --git a/test/rules/test_meta_video_links.py b/test/rules/test_meta_video_links.py index ba3c03b3d6..3772ea270f 100644 --- a/test/rules/test_meta_video_links.py +++ b/test/rules/test_meta_video_links.py @@ -8,6 +8,8 @@ video_links: - url: https://www.youtube.com/watch?v=aWmRepTSFKs&feature=youtu.be title: Proper format + - url: https://drive.google.com/file/d/1spYR51l8SqQqvAhSdZE7/view + title: Check for VIDEO_REGEXP validity and break - https://www.youtube.com/watch?v=aWmRepTSFKs&feature=youtu.be - my_bad_key: https://www.youtube.com/watch?v=aWmRepTSFKs&feature=youtu.be title: This has a bad key @@ -15,6 +17,12 @@ title: Bad format of url """ +META_NO_GALAXY_INFO = """ +galaxy_information: + video_links: + - url: https://www.youtube.com/watch?v=aWmRepTSFKs&feature=youtu.be +""" + def test_video_links() -> None: """Test meta_video_links.""" @@ -26,3 +34,13 @@ def test_video_links() -> None: assert "Expected item in 'video_links' to be a dictionary" in str(results) assert "'video_links' to contain only keys 'url' and 'title'" in str(results) assert "URL format 'www.acme.com/vid' is not recognized" in str(results) + + +def test_meta_video_links_no_galaxy_info() -> None: + """Test meta_video_links.""" + collection = RulesCollection() + collection.register(MetaVideoLinksRule()) + runner = RunFromText(collection) + + results = runner.run_role_meta_main(META_NO_GALAXY_INFO) + assert len(results) == 0