def test_add_repo_key_path(self): salt_mock = { "cp.cache_file": MagicMock(return_value="path"), "lowpkg.import_gpg_key": MagicMock(return_value=True), } with patch("salt.utils.files.fopen", mock_open(read_data="text")), patch.dict( yumpkg.__salt__, salt_mock ): self.assertTrue(yumpkg.add_repo_key(path="path", root="/mnt")) salt_mock["cp.cache_file"].assert_called_once_with("path", "base") salt_mock["lowpkg.import_gpg_key"].assert_called_once_with("text", "/mnt")
def test_add_repo_key_text(self): salt_mock = {"lowpkg.import_gpg_key": MagicMock(return_value=True)} with patch.dict(yumpkg.__salt__, salt_mock): self.assertTrue(yumpkg.add_repo_key(text="text", root="/mnt")) salt_mock["lowpkg.import_gpg_key"].assert_called_once_with( "text", "/mnt")
def test_add_repo_key_fail(self): with self.assertRaises(SaltInvocationError): yumpkg.add_repo_key() with self.assertRaises(SaltInvocationError): yumpkg.add_repo_key(path="path", text="text")