def create_playbook(self, name: Optional[str] = None):
     if name is None:
         name = f'playbook{len(self.playbooks)}'
     playbook = Playbook(self._playbooks_path, name, self._repo)
     playbook.create_default_playbook()
     self.playbooks.append(playbook)
     return playbook
Exemple #2
0
def test_get_ignore_pack_tests__ignore_test(tmpdir, mocker):
    """
    Given
    - Pack have .pack-ignore file
    - There are skipped tests in .pack-ignore
    When
    - Collecting packs' ignored tests - running `get_ignore_pack_tests()`
    Then:
    - returns a list with the skipped tests
    """
    fake_pack_name = 'FakeTestPack'
    fake_test_name = 'FakeTestPlaybook'
    expected_id = 'sample playbook'

    # prepare repo
    repo = Repo(tmpdir)
    packs_path = Path(repo.path) / PACKS_DIR
    pack = Pack(packs_path, fake_pack_name, repo)
    test_playbook_path = packs_path / fake_pack_name / TEST_PLAYBOOKS_DIR
    test_playbook = Playbook(test_playbook_path, fake_test_name, repo, is_test_playbook=True)
    pack_ignore_path = os.path.join(pack.path, PACKS_PACK_IGNORE_FILE_NAME)

    # prepare .pack-ignore
    with open(pack_ignore_path, 'a') as pack_ignore_f:
        pack_ignore_f.write("[file:TestIntegration.yml]\nignore=IN126\n\n"
                            f"[file:{test_playbook.name}]\nignore=auto-test")

    # prepare mocks
    mocker.patch.object(tools, "get_pack_ignore_file_path", return_value=pack_ignore_path)
    mocker.patch.object(os.path, "join", return_value=str(test_playbook_path / (test_playbook.name + ".yml")))

    ignore_test_set = get_ignore_pack_skipped_tests(fake_pack_name)
    assert len(ignore_test_set) == 1
    assert expected_id in ignore_test_set
Exemple #3
0
 def create_playbook(
         self,
         name: Optional[str] = None,
         yml: Optional[dict] = None,
         readme: Optional[str] = None,
 ) -> Playbook:
     if name is None:
         name = f'playbook-{len(self.playbooks)}.yml'
     if yml is None:
         yml = {}
     playbook = Playbook(self._playbooks_path, name, self._repo)
     playbook.build(
         yml,
         readme,
     )
     self.playbooks.append(playbook)
     return playbook
Exemple #4
0
 def create_test_playbook(
         self,
         name: Optional[str] = None,
         yml: Optional[dict] = None,
         readme: Optional[str] = None,
         changelog: Optional[str] = None,
 ) -> Playbook:
     if name is None:
         name = f'playbook-{len(self.test_playbooks)}'
     if yml is None:
         yml = {}
     playbook = Playbook(self._test_playbooks_path, name, self._repo, is_test_playbook=True)
     playbook.build(
         yml,
         readme,
     )
     self.test_playbooks.append(playbook)
     return playbook