File: TestMetaVideoLinks.py

package info (click to toggle)
ansible-lint 4.1.0%2Bdfsg.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,096 kB
  • sloc: python: 3,373; sh: 4; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 1,086 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import unittest

from ansiblelint import RulesCollection
from ansiblelint.rules.MetaVideoLinksRule import MetaVideoLinksRule
from test import RunFromText

META_VIDEO_LINKS = '''
galaxy_info:
  video_links:
  - url: https://youtu.be/aWmRepTSFKs
    title: Proper format
  - https://youtu.be/this_is_not_a_dictionary
  - my_bad_key: https://youtu.be/aWmRepTSFKs
    title: This has a bad key
  - url: www.myvid.com/vid
    title: Bad format of url
'''


class TestMetaVideoLinks(unittest.TestCase):
    collection = RulesCollection()
    collection.register(MetaVideoLinksRule())

    def setUp(self):
        self.runner = RunFromText(self.collection)

    def test_video_links(self):
        results = self.runner.run_role_meta_main(META_VIDEO_LINKS)
        self.assertIn("Expected item in 'video_links' to be a dictionary",
                      str(results))
        self.assertIn("'video_links' to contain only keys 'url' and 'title'",
                      str(results))
        self.assertIn("URL format 'www.myvid.com/vid' is not recognized",
                      str(results))