Skip to content

Commit 24ddc59

Browse files
committed
[tests] Added unit tests
1 parent d79900b commit 24ddc59

File tree

6 files changed

+300
-12
lines changed

6 files changed

+300
-12
lines changed

pyatlan/model/packages/oracle_crawler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ class AuthType(str, Enum):
4040
BASIC = "basic"
4141
KERBEROS = "kerberos"
4242

43-
class AWS_AUTH_METHOD(str, Enum):
43+
class AwsAuthMethod(str, Enum):
4444
IAM = "iam"
4545
IAM_ASSUME_ROLE = "iam-assume-role"
4646
ACCESS_KEY = "access-key"
4747

48-
class AZURE_AUTH_METHOD(str, Enum):
48+
class AzureAuthMethod(str, Enum):
4949
MANAGED_IDENTITY = "managed_identity"
5050
SERVICE_PRINCIPAL = "service_principal"
5151

@@ -130,8 +130,8 @@ def agent_config(
130130
secret_store: SecretStore = SecretStore.CUSTOM,
131131
auth_type: AuthType = AuthType.BASIC,
132132
aws_region: str = "us-east-1",
133-
aws_auth_method: AWS_AUTH_METHOD = AWS_AUTH_METHOD.IAM,
134-
azure_auth_method: AZURE_AUTH_METHOD = AZURE_AUTH_METHOD.MANAGED_IDENTITY,
133+
aws_auth_method: AwsAuthMethod = AwsAuthMethod.IAM,
134+
azure_auth_method: AzureAuthMethod = AzureAuthMethod.MANAGED_IDENTITY,
135135
secret_path: Optional[str] = None,
136136
principal: Optional[str] = None,
137137
azure_vault_name: Optional[str] = None,

tests/unit/data/package_requests/oracle_crawler_basic.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@
7474
"name": "credentials-fetch-strategy",
7575
"value": "credential_guid"
7676
},
77-
{
78-
"name": "credential-guid",
79-
"value": "{{credentialGuid}}"
80-
},
8177
{
8278
"name": "publish-mode",
8379
"value": "production"
@@ -93,6 +89,10 @@
9389
{
9490
"name": "connection",
9591
"value": "{\"typeName\": \"Connection\", \"attributes\": {\"qualifiedName\": \"default/oracle/123456\", \"name\": \"test-oracle-conn\", \"adminUsers\": [], \"adminGroups\": [], \"connectorName\": \"oracle\", \"isDiscoverable\": true, \"isEditable\": false, \"adminRoles\": [\"admin-guid-1234\"], \"category\": \"warehouse\", \"allowQuery\": true, \"allowQueryPreview\": true, \"rowLimit\": 10000, \"defaultCredentialGuid\": \"{{credentialGuid}}\", \"sourceLogo\": \"https://docs.oracle.com/sp_common/book-template/ohc-common/img/favicon.ico\"}, \"guid\": \"-1234567890000000000000000\"}"
92+
},
93+
{
94+
"name": "credential-guid",
95+
"value": "{{credentialGuid}}"
9696
}
9797
]
9898
},
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"metadata": {
3+
"annotations": {
4+
"orchestration.atlan.com/allowSchedule": "true",
5+
"orchestration.atlan.com/categories": "warehouse,crawler",
6+
"orchestration.atlan.com/dependentPackage": "",
7+
"orchestration.atlan.com/docsUrl": "https://ask.atlan.com/hc/en-us/articles/6849958872861",
8+
"orchestration.atlan.com/emoji": "🚀",
9+
"orchestration.atlan.com/icon": "https://docs.oracle.com/sp_common/book-template/ohc-common/img/favicon.ico",
10+
"orchestration.atlan.com/logo": "https://docs.oracle.com/sp_common/book-template/ohc-common/img/favicon.ico",
11+
"orchestration.atlan.com/marketplaceLink": "https://packages.atlan.com/-/web/detail/@atlan/oracle",
12+
"orchestration.atlan.com/name": "Oracle Assets",
13+
"package.argoproj.io/author": "Atlan",
14+
"package.argoproj.io/description": "Package to crawl Oracle assets and publish to Atlan for discovery",
15+
"package.argoproj.io/homepage": "https://packages.atlan.com/-/web/detail/@atlan/oracle",
16+
"package.argoproj.io/keywords": "[\"oracle\",\"warehouse\",\"connector\",\"crawler\"]",
17+
"package.argoproj.io/name": "@atlan/oracle",
18+
"package.argoproj.io/registry": "https://packages.atlan.com",
19+
"package.argoproj.io/repository": "git+https://github.com/atlanhq/marketplace-packages.git",
20+
"package.argoproj.io/support": "[email protected]",
21+
"orchestration.atlan.com/atlanName": "atlan-oracle-default-oracle-123456"
22+
},
23+
"labels": {
24+
"orchestration.atlan.com/certified": "true",
25+
"orchestration.atlan.com/source": "oracle",
26+
"orchestration.atlan.com/sourceCategory": "warehouse",
27+
"orchestration.atlan.com/type": "connector",
28+
"orchestration.atlan.com/verified": "true",
29+
"package.argoproj.io/installer": "argopm",
30+
"package.argoproj.io/name": "a-t-ratlans-l-a-s-horacle",
31+
"package.argoproj.io/registry": "httpsc-o-l-o-ns-l-a-s-hs-l-a-s-hpackages.atlan.com",
32+
"orchestration.atlan.com/default-oracle-123456": "true",
33+
"orchestration.atlan.com/atlan-ui": "true"
34+
},
35+
"name": "atlan-oracle-123456",
36+
"namespace": "default"
37+
},
38+
"spec": {
39+
"entrypoint": "main",
40+
"templates": [
41+
{
42+
"name": "main",
43+
"dag": {
44+
"tasks": [
45+
{
46+
"name": "run",
47+
"arguments": {
48+
"parameters": [
49+
{
50+
"name": "extraction-method",
51+
"value": "agent"
52+
},
53+
{
54+
"name": "agent-json",
55+
"value": "{\"host\": \"test.oracle.com\", \"port\": 1234, \"auth-type\": \"basic\", \"database\": \"test-db\", \"extra-service\": \"test-sid\", \"agent-name\": \"test-agent\", \"secret-manager\": \"awssecretmanager\", \"user-env\": null, \"password-env\": null, \"agent-config\": {\"test\": \"config\"}, \"aws-auth-method\": \"iam-assume-role\", \"aws-region\": \"us-east-1\", \"azure-auth-method\": \"managed_identity\", \"secret-path\": \"some/test/path\"}"
56+
},
57+
{
58+
"name": "include-filter-agent",
59+
"value": "{\"^t1$\": [\"^t11$\", \"^t12$\", \"^t13$\"]}"
60+
},
61+
{
62+
"name": "exclude-filter-agent",
63+
"value": "{\"^t2$\": [\"^t21$\", \"^t22$\", \"^t23$\"]}"
64+
},
65+
{
66+
"name": "use-jdbc-internal-methods",
67+
"value": "true"
68+
},
69+
{
70+
"name": "use-source-schema-filtering",
71+
"value": "false"
72+
},
73+
{
74+
"name": "credentials-fetch-strategy",
75+
"value": "credential_guid"
76+
},
77+
{
78+
"name": "publish-mode",
79+
"value": "production"
80+
},
81+
{
82+
"name": "atlas-auth-type",
83+
"value": "internal"
84+
},
85+
{
86+
"name": "advanced-config-strategy",
87+
"value": "custom"
88+
},
89+
{
90+
"name": "connection",
91+
"value": "{\"typeName\": \"Connection\", \"attributes\": {\"qualifiedName\": \"default/oracle/123456\", \"name\": \"test-oracle-conn\", \"adminUsers\": [], \"adminGroups\": [], \"connectorName\": \"oracle\", \"isDiscoverable\": true, \"isEditable\": false, \"adminRoles\": [\"admin-guid-1234\"], \"category\": \"warehouse\", \"allowQuery\": true, \"allowQueryPreview\": true, \"rowLimit\": 10000, \"defaultCredentialGuid\": \"{{credentialGuid}}\", \"sourceLogo\": \"https://docs.oracle.com/sp_common/book-template/ohc-common/img/favicon.ico\"}, \"guid\": \"-1234567890000000000000000\"}"
92+
}
93+
]
94+
},
95+
"templateRef": {
96+
"name": "atlan-oracle",
97+
"template": "main",
98+
"clusterScope": true
99+
}
100+
}
101+
]
102+
}
103+
}
104+
],
105+
"workflowMetadata": {
106+
"annotations": {
107+
"package.argoproj.io/name": "@atlan/oracle"
108+
}
109+
}
110+
},
111+
"payload": []
112+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"metadata": {
3+
"annotations": {
4+
"orchestration.atlan.com/allowSchedule": "true",
5+
"orchestration.atlan.com/categories": "warehouse,crawler",
6+
"orchestration.atlan.com/dependentPackage": "",
7+
"orchestration.atlan.com/docsUrl": "https://ask.atlan.com/hc/en-us/articles/6849958872861",
8+
"orchestration.atlan.com/emoji": "🚀",
9+
"orchestration.atlan.com/icon": "https://docs.oracle.com/sp_common/book-template/ohc-common/img/favicon.ico",
10+
"orchestration.atlan.com/logo": "https://docs.oracle.com/sp_common/book-template/ohc-common/img/favicon.ico",
11+
"orchestration.atlan.com/marketplaceLink": "https://packages.atlan.com/-/web/detail/@atlan/oracle",
12+
"orchestration.atlan.com/name": "Oracle Assets",
13+
"package.argoproj.io/author": "Atlan",
14+
"package.argoproj.io/description": "Package to crawl Oracle assets and publish to Atlan for discovery",
15+
"package.argoproj.io/homepage": "https://packages.atlan.com/-/web/detail/@atlan/oracle",
16+
"package.argoproj.io/keywords": "[\"oracle\",\"warehouse\",\"connector\",\"crawler\"]",
17+
"package.argoproj.io/name": "@atlan/oracle",
18+
"package.argoproj.io/registry": "https://packages.atlan.com",
19+
"package.argoproj.io/repository": "git+https://github.com/atlanhq/marketplace-packages.git",
20+
"package.argoproj.io/support": "[email protected]",
21+
"orchestration.atlan.com/atlanName": "atlan-oracle-default-oracle-123456"
22+
},
23+
"labels": {
24+
"orchestration.atlan.com/certified": "true",
25+
"orchestration.atlan.com/source": "oracle",
26+
"orchestration.atlan.com/sourceCategory": "warehouse",
27+
"orchestration.atlan.com/type": "connector",
28+
"orchestration.atlan.com/verified": "true",
29+
"package.argoproj.io/installer": "argopm",
30+
"package.argoproj.io/name": "a-t-ratlans-l-a-s-horacle",
31+
"package.argoproj.io/registry": "httpsc-o-l-o-ns-l-a-s-hs-l-a-s-hpackages.atlan.com",
32+
"orchestration.atlan.com/default-oracle-123456": "true",
33+
"orchestration.atlan.com/atlan-ui": "true"
34+
},
35+
"name": "atlan-oracle-123456",
36+
"namespace": "default"
37+
},
38+
"spec": {
39+
"entrypoint": "main",
40+
"templates": [
41+
{
42+
"name": "main",
43+
"dag": {
44+
"tasks": [
45+
{
46+
"name": "run",
47+
"arguments": {
48+
"parameters": [
49+
{
50+
"name": "extraction-method",
51+
"value": "agent"
52+
},
53+
{
54+
"name": "agent-json",
55+
"value": "{\"host\": \"test.oracle.com\", \"port\": 1234, \"auth-type\": \"kerberos\", \"database\": \"test-db\", \"extra-service\": \"test-sid\", \"agent-name\": \"test-agent\", \"secret-manager\": \"secretinjectionenvironment\", \"user-env\": \"test-user-env\", \"password-env\": \"test-pass-env\", \"agent-config\": {\"test\": \"config\"}, \"aws-auth-method\": \"iam\", \"aws-region\": \"us-east-1\", \"azure-auth-method\": \"managed_identity\", \"extra-principal\": \"test-principal\"}"
56+
},
57+
{
58+
"name": "include-filter-agent",
59+
"value": "{\"^t1$\": [\"^t11$\", \"^t12$\", \"^t13$\"]}"
60+
},
61+
{
62+
"name": "exclude-filter-agent",
63+
"value": "{\"^t2$\": [\"^t21$\", \"^t22$\", \"^t23$\"]}"
64+
},
65+
{
66+
"name": "use-jdbc-internal-methods",
67+
"value": "true"
68+
},
69+
{
70+
"name": "use-source-schema-filtering",
71+
"value": "false"
72+
},
73+
{
74+
"name": "credentials-fetch-strategy",
75+
"value": "credential_guid"
76+
},
77+
{
78+
"name": "publish-mode",
79+
"value": "production"
80+
},
81+
{
82+
"name": "atlas-auth-type",
83+
"value": "internal"
84+
},
85+
{
86+
"name": "advanced-config-strategy",
87+
"value": "custom"
88+
},
89+
{
90+
"name": "connection",
91+
"value": "{\"typeName\": \"Connection\", \"attributes\": {\"qualifiedName\": \"default/oracle/123456\", \"name\": \"test-oracle-conn\", \"adminUsers\": [], \"adminGroups\": [], \"connectorName\": \"oracle\", \"isDiscoverable\": true, \"isEditable\": false, \"adminRoles\": [\"admin-guid-1234\"], \"category\": \"warehouse\", \"allowQuery\": true, \"allowQueryPreview\": true, \"rowLimit\": 10000, \"defaultCredentialGuid\": \"{{credentialGuid}}\", \"sourceLogo\": \"https://docs.oracle.com/sp_common/book-template/ohc-common/img/favicon.ico\"}, \"guid\": \"-1234567890000000000000000\"}"
92+
}
93+
]
94+
},
95+
"templateRef": {
96+
"name": "atlan-oracle",
97+
"template": "main",
98+
"clusterScope": true
99+
}
100+
}
101+
]
102+
}
103+
}
104+
],
105+
"workflowMetadata": {
106+
"annotations": {
107+
"package.argoproj.io/name": "@atlan/oracle"
108+
}
109+
}
110+
},
111+
"payload": []
112+
}

tests/unit/data/package_requests/oracle_crawler_offline.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@
7070
"name": "credentials-fetch-strategy",
7171
"value": "credential_guid"
7272
},
73-
{
74-
"name": "credential-guid",
75-
"value": "{{credentialGuid}}"
76-
},
7773
{
7874
"name": "publish-mode",
7975
"value": "production"
@@ -89,6 +85,10 @@
8985
{
9086
"name": "connection",
9187
"value": "{\"typeName\": \"Connection\", \"attributes\": {\"qualifiedName\": \"default/oracle/123456\", \"name\": \"test-oracle-conn\", \"adminUsers\": [], \"adminGroups\": [], \"connectorName\": \"oracle\", \"isDiscoverable\": true, \"isEditable\": false, \"adminRoles\": [\"admin-guid-1234\"], \"category\": \"warehouse\", \"allowQuery\": true, \"allowQueryPreview\": true, \"rowLimit\": 10000, \"defaultCredentialGuid\": \"{{credentialGuid}}\", \"sourceLogo\": \"https://docs.oracle.com/sp_common/book-template/ohc-common/img/favicon.ico\"}, \"guid\": \"-1234567890000000000000000\"}"
88+
},
89+
{
90+
"name": "credential-guid",
91+
"value": "{{credentialGuid}}"
9292
}
9393
]
9494
},

tests/unit/test_packages.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
)
9595
ORACLE_CRAWLER_BASIC = "oracle_crawler_basic.json"
9696
ORACLE_CRAWLER_OFFLINE = "oracle_crawler_offline.json"
97+
ORACLE_CRAWLER_BASIC_AGENT = "oracle_crawler_basic_agent.json"
98+
ORACLE_CRAWLER_KERBEROS_AGENT = "oracle_crawler_kerberos_agent.json"
9799
LINEAGE_BUILDER_S3 = "lineage_builder_s3.json"
98100
LINEAGE_BUILDER_GCS = "lineage_builder_gcs.json"
99101
LINEAGE_BUILDER_ADLS = "lineage_builder_adls.json"
@@ -1444,6 +1446,68 @@ def test_oracle_crawler(mock_package_env):
14441446
request_json = loads(oracle_crawler_offline.json(by_alias=True, exclude_none=True))
14451447
assert request_json == load_json(ORACLE_CRAWLER_OFFLINE)
14461448

1449+
oracle_crawler_basic_agent = (
1450+
OracleCrawler(
1451+
connection_name="test-oracle-conn",
1452+
admin_roles=["admin-guid-1234"],
1453+
admin_groups=None,
1454+
admin_users=None,
1455+
)
1456+
.agent_config(
1457+
hostname="test.oracle.com",
1458+
port=1234,
1459+
auth_type=OracleCrawler.AuthType.BASIC,
1460+
default_db_name="test-db",
1461+
sid="test-sid",
1462+
agent_name="test-agent",
1463+
aws_region="us-east-1",
1464+
aws_auth_method=OracleCrawler.AwsAuthMethod.IAM_ASSUME_ROLE,
1465+
secret_store=OracleCrawler.SecretStore.AWS_SECRET_MANAGER,
1466+
secret_path="some/test/path",
1467+
agent_custom_config={"test": "config"},
1468+
)
1469+
.include(assets={"t1": ["t11", "t12", "t13"]})
1470+
.exclude(assets={"t2": ["t21", "t22", "t23"]})
1471+
.jdbc_internal_methods(True)
1472+
.source_level_filtering(False)
1473+
.to_workflow()
1474+
)
1475+
request_json = loads(
1476+
oracle_crawler_basic_agent.json(by_alias=True, exclude_none=True)
1477+
)
1478+
assert request_json == load_json(ORACLE_CRAWLER_BASIC_AGENT)
1479+
1480+
oracle_crawler_kerberos_agent = (
1481+
OracleCrawler(
1482+
connection_name="test-oracle-conn",
1483+
admin_roles=["admin-guid-1234"],
1484+
admin_groups=None,
1485+
admin_users=None,
1486+
)
1487+
.agent_config(
1488+
hostname="test.oracle.com",
1489+
port=1234,
1490+
auth_type=OracleCrawler.AuthType.KERBEROS,
1491+
default_db_name="test-db",
1492+
sid="test-sid",
1493+
agent_name="test-agent",
1494+
principal="test-principal",
1495+
secret_store=OracleCrawler.SecretStore.SECRET_INJECTION_ENV,
1496+
user_env_var="test-user-env",
1497+
password_env_var="test-pass-env",
1498+
agent_custom_config={"test": "config"},
1499+
)
1500+
.include(assets={"t1": ["t11", "t12", "t13"]})
1501+
.exclude(assets={"t2": ["t21", "t22", "t23"]})
1502+
.jdbc_internal_methods(True)
1503+
.source_level_filtering(False)
1504+
.to_workflow()
1505+
)
1506+
request_json = loads(
1507+
oracle_crawler_kerberos_agent.json(by_alias=True, exclude_none=True)
1508+
)
1509+
assert request_json == load_json(ORACLE_CRAWLER_KERBEROS_AGENT)
1510+
14471511

14481512
def test_lineage_builder(mock_package_env):
14491513
lineage_builder_s3 = (

0 commit comments

Comments
 (0)