2021-07-20 19:13:49 -07:00
|
|
|
import unittest.mock
|
|
|
|
|
2021-06-11 17:27:34 -07:00
|
|
|
import pytest
|
|
|
|
|
2021-07-20 19:13:49 -07:00
|
|
|
from datahub.ingestion.api.common import PipelineContext
|
2021-07-26 13:06:52 -07:00
|
|
|
from datahub.ingestion.source.sql.oracle import OracleConfig, OracleSource
|
2021-06-11 17:27:34 -07:00
|
|
|
|
|
|
|
|
|
|
|
def test_oracle_config():
|
|
|
|
base_config = {
|
|
|
|
"username": "user",
|
|
|
|
"password": "password",
|
|
|
|
"host_port": "host:1521",
|
|
|
|
}
|
|
|
|
|
|
|
|
config = OracleConfig.parse_obj(
|
|
|
|
{
|
|
|
|
**base_config,
|
|
|
|
"service_name": "svc01",
|
|
|
|
}
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
config.get_sql_alchemy_url()
|
2024-11-14 12:46:27 +05:30
|
|
|
== "oracle://user:password@host:1521/?service_name=svc01"
|
2021-06-11 17:27:34 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
config = OracleConfig.parse_obj(
|
|
|
|
{
|
|
|
|
**base_config,
|
|
|
|
"database": "db",
|
|
|
|
"service_name": "svc01",
|
|
|
|
}
|
|
|
|
)
|
2021-07-20 19:13:49 -07:00
|
|
|
|
|
|
|
with unittest.mock.patch(
|
2021-07-26 13:06:52 -07:00
|
|
|
"datahub.ingestion.source.sql.sql_common.SQLAlchemySource.get_workunits"
|
2021-07-20 19:13:49 -07:00
|
|
|
):
|
|
|
|
OracleSource.create(
|
|
|
|
{
|
|
|
|
**base_config,
|
|
|
|
"service_name": "svc01",
|
|
|
|
},
|
|
|
|
PipelineContext("test-oracle-config"),
|
|
|
|
).get_workunits()
|