Skip to content

Commit

Permalink
Fix: don't rely on a specific plugin for the test.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Sep 27, 2024
1 parent 7431c76 commit 5facbff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions test_opensearchpy/test_async/test_plugins_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# GitHub history for details.


import re
import warnings

import pytest
Expand All @@ -24,8 +25,7 @@ async def test_plugins_client(self) -> None:
client = AsyncOpenSearch()
# testing double-init here
client.plugins.__init__(client) # type: ignore # pylint: disable=unnecessary-dunder-call
assert (
str(w[0].message)
== "Cannot load `alerting` directly to AsyncOpenSearch as it already exists. Use "
"`AsyncOpenSearch.plugin.alerting` instead."
assert re.match(
r"Cannot load `\w+` directly to AsyncOpenSearch as it already exists. Use `AsyncOpenSearch.plugin.\w+` instead.",
str(w[0].message),
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.

import re

from opensearchpy.client import OpenSearch

from ...test_cases import TestCase
Expand All @@ -18,8 +20,9 @@ def test_plugins_client(self) -> None:
client = OpenSearch()
# double-init
client.plugins.__init__(client) # type: ignore # pylint: disable=unnecessary-dunder-call
self.assertEqual(
str(w.warnings[0].message),
"Cannot load `alerting` directly to OpenSearch as "
"it already exists. Use `OpenSearch.plugin.alerting` instead.",
self.assertTrue(
re.match(
r"Cannot load `\w+` directly to OpenSearch as it already exists. Use `OpenSearch.plugin.\w+` instead.",
str(w.warnings[0].message),
)
)

0 comments on commit 5facbff

Please sign in to comment.