Skip to content

Commit

Permalink
Create opensearch_external_url_formatter_test.py
Browse files Browse the repository at this point in the history
Add a test file for opensearch_external_url_formatter
  • Loading branch information
luffynextgen authored Nov 17, 2023
1 parent 42762f9 commit 8e07132
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/opensearch_external_url_formatter_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from typing import Any
import os
import pytest

import requests
from requests.auth import AuthBase, HTTPBasicAuth

from elastalert.opensearch_external_url_formatter import AbsoluteOpensearchExternalUrlFormatter
from elastalert.opensearch_external_url_formatter import OpensearchExternalUrlFormatter
from elastalert.opensearch_external_url_formatter import create_opensearch_external_url_formatter

from elastalert.auth import RefeshableAWSRequestsAuth
from elastalert.util import EAException

from unittest import mock


class AbsoluteFormatTestCase:
def __init__(
self,
base_url: str,
relative_url: str,
expected_url: str,
) -> None:
self.base_url = base_url
self.relative_url = relative_url
self.expected_url = expected_url


@pytest.mark.parametrize("test_case", [
# Relative to OpenSearch Dashboards
AbsoluteFormatTestCase(
base_url='http://opensearch.test.org/_dashboards/',
relative_url='app/dev_tools#/console',
expected_url='http://opensearch.test.org/_dashboards/app/dev_tools#/console'
),
])


def test_absolute_opensearch_external_url_formatter(
test_case: AbsoluteFormatTestCase
):
formatter = AbsoluteOpensearchExternalUrlFormatter(
base_url=test_case.base_url
)
actualUrl = formatter.format(test_case.relative_url)
print(actualUrl)
assert actualUrl == test_case.expected_url

0 comments on commit 8e07132

Please sign in to comment.