def test_sync_apps_missing_bootstrap_element_in_bootstrap_yaml(self): self.yaml_file_load_mock.side_effect = lambda file_path: { "/tmp/root-config-repo/bootstrap/values.yaml": { }, # empty bootstrap yaml }[file_path] args = SyncAppsCommand.Args( username="******", password="******", git_user="******", git_email="GIT_EMAIL", root_organisation="ROOT_ORGA", root_repository_name="ROOT_REPO", organisation="TEAM_ORGA", repository_name="TEAM_REPO", git_provider=GitProvider.GITHUB, git_provider_url=None, ) try: SyncAppsCommand(ARGS).execute() self.fail() except GitOpsException as ex: self.assertEqual( "Cannot find key 'bootstrap' in 'bootstrap/values.yaml'", str(ex))
import logging import os import unittest from unittest.mock import call from gitopscli.git_api import GitProvider, GitRepo, GitRepoApi, GitRepoApiFactory from gitopscli.commands.sync_apps import SyncAppsCommand from gitopscli.io_api.yaml_util import merge_yaml_element, yaml_file_load from gitopscli.gitops_exception import GitOpsException from .mock_mixin import MockMixin ARGS = SyncAppsCommand.Args( username="******", password="******", git_user="******", git_email="GIT_EMAIL", root_organisation="ROOT_ORGA", root_repository_name="ROOT_REPO", organisation="TEAM_ORGA", repository_name="TEAM_REPO", git_provider=GitProvider.GITHUB, git_provider_url=None, ) class SyncAppsCommandTest(MockMixin, unittest.TestCase): def setUp(self): self.init_mock_manager(SyncAppsCommand) self.os_mock = self.monkey_patch(os) self.os_mock.path.isdir.return_value = True self.os_mock.path.join.side_effect = os.path.join self.os_mock.listdir.return_value = ["my-app"]