Skip to content

Commit

Permalink
Add full coverage to meta_video_links rule (#3036)
Browse files Browse the repository at this point in the history
Co-authored-by: Ajinkya Udgirkar <audgirka@redhat.com>
  • Loading branch information
audgirka and audgirka committed Feb 15, 2023
1 parent b255f2a commit 8592a4f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions test/rules/test_meta_video_links.py
Expand Up @@ -8,13 +8,21 @@
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
- url: www.acme.com/vid
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."""
Expand All @@ -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

0 comments on commit 8592a4f

Please sign in to comment.