示例#1
0
 def test_repo_managed_import_failed_repo_manage(self):
     ret = {
         "name": "state_id",
         "changes": {},
         "result": False,
         "comment":
         "'helm.repo_manage' modules not available on this minion.",
     }
     self.assertEqual(helm.repo_managed("state_id"), ret)
示例#2
0
 def test_repo_managed_import_failed_repo_update(self):
     mock_helm_modules = {"helm.repo_manage": MagicMock(return_value=True)}
     with patch.dict(helm.__salt__, mock_helm_modules):
         ret = {
             "name":
             "state_id",
             "changes": {},
             "result":
             False,
             "comment":
             "'helm.repo_update' modules not available on this minion.",
         }
         self.assertEqual(helm.repo_managed("state_id"), ret)
示例#3
0
 def test_repo_managed_failed(self):
     result_changes = {"added": True, "removed": True, "failed": True}
     mock_helm_modules = {
         "helm.repo_manage": MagicMock(return_value=result_changes),
         "helm.repo_update": MagicMock(return_value=True),
     }
     with patch.dict(helm.__salt__, mock_helm_modules):
         ret = {
             "name": "state_id",
             "result": False,
             "comment": "Failed to add or remove some repositories.",
             "changes": result_changes,
         }
         self.assertEqual(helm.repo_managed("state_id"), ret)
示例#4
0
 def test_repo_managed_is_testing(self):
     mock_helm_modules = {
         "helm.repo_manage": MagicMock(return_value=True),
         "helm.repo_update": MagicMock(return_value=True),
     }
     with patch.dict(helm.__salt__, mock_helm_modules):
         mock__opts__ = {"test": MagicMock(return_value=True)}
         with patch.dict(helm.__opts__, mock__opts__):
             ret = {
                 "name": "state_id",
                 "result": None,
                 "comment": "Helm repo would have been managed.",
                 "changes": {},
             }
             self.assertEqual(helm.repo_managed("state_id"), ret)
示例#5
0
 def test_repo_managed_success_with_update(self):
     result_changes = {"added": True, "removed": True, "failed": False}
     mock_helm_modules = {
         "helm.repo_manage": MagicMock(return_value=result_changes),
         "helm.repo_update": MagicMock(return_value=True),
     }
     result_wanted = result_changes
     result_wanted.update({"repo_update": True})
     with patch.dict(helm.__salt__, mock_helm_modules):
         ret = {
             "name": "state_id",
             "result": True,
             "comment": "Repositories were added or removed.",
             "changes": result_wanted,
         }
         self.assertEqual(helm.repo_managed("state_id"), ret)