-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: mgorsk1 <[email protected]>
- Loading branch information
Showing
5 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright Contributors to the Amundsen project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
import unittest | ||
from typing import Any, Dict # noqa: F401 | ||
from unittest.mock import MagicMock, patch | ||
|
||
from flask import Flask | ||
|
||
import metadata_service | ||
from metadata_service.config import PROXY_CLIENTS | ||
from metadata_service.proxy import get_proxy_client | ||
|
||
|
||
class TestCreateProxy(unittest.TestCase): | ||
proxies = { | ||
'NEO4J': {'host': 'bolt://neo4j.com', 'port': 7687, 'password': 'neo4j'}, | ||
'ATLAS': {'host': 'http://atlas.com', 'port': 21000, 'password': 'atlas'} | ||
} | ||
|
||
@patch('neo4j.GraphDatabase.driver', MagicMock()) | ||
def test_proxy_client_creation(self) -> None: | ||
for proxy, spec in self.proxies.items(): | ||
with self.subTest(): | ||
config = metadata_service.config.LocalConfig() | ||
metadata_service.proxy._proxy_client = None | ||
|
||
config.PROXY_CLIENT = PROXY_CLIENTS[proxy] | ||
config.PROXY_HOST = spec['host'] # type: ignore | ||
config.PROXY_PORT = spec['port'] # type: ignore | ||
|
||
app = Flask(__name__) | ||
|
||
app.config.from_object(config) | ||
|
||
with app.app_context(): | ||
try: | ||
get_proxy_client() | ||
assert True | ||
except Exception as e: | ||
assert False |