Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Data Flow
Data Ingestion
Ingestion DAGs
Commits
2e64dc73
Commit
2e64dc73
authored
Apr 15, 2021
by
Yan Sushchynski (EPAM)
Browse files
GONRG-2147: Fix double colon in refs
parent
4ec0892f
Pipeline
#36435
passed with stages
in 9 minutes and 10 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/dags/libs/manifest_analyzer.py
View file @
2e64dc73
...
...
@@ -97,8 +97,11 @@ class EntityNode(object):
content
=
json
.
dumps
(
self
.
content
)
for
parent
in
self
.
parents
:
if
parent
.
system_srn
:
# ':' at the end is for showing that it is reference.
content
=
content
.
replace
(
parent
.
srn
,
f
"
{
parent
.
system_srn
}
:"
)
# ':' at the end is for showing that it is reference if parent srn was surrogate-key.
if
"surrogate-key"
in
parent
.
system_srn
:
content
=
content
.
replace
(
parent
.
srn
,
f
"
{
parent
.
system_srn
}
:"
)
else
:
content
=
content
.
replace
(
parent
.
srn
,
f
"
{
parent
.
system_srn
}
"
)
self
.
content
=
json
.
loads
(
content
)
...
...
tests/plugin-unit-tests/test_manifest_analyzer.py
View file @
2e64dc73
...
...
@@ -86,7 +86,10 @@ class TestManifestAnalyzer(object):
return
manifest_analyzer
def
process_entity
(
self
,
entity
:
EntityNode
)
->
str
:
return
f
"system_srn:
{
entity
.
srn
}
"
if
"surrogate-key"
in
entity
.
srn
:
return
f
"system_srn:
{
entity
.
srn
}
"
else
:
return
entity
.
srn
def
index_in_queue_by_srn
(
self
,
...
...
@@ -200,3 +203,50 @@ class TestManifestAnalyzer(object):
logger
.
info
(
f
"Processed entities:
{
manifest_analyzer
.
processed_entities
}
"
)
logger
.
info
(
f
"Unprocessed entities
{
manifest_analyzer
.
unprocessed_entities
}
"
)
assert
"surrogate-key:wpc-1"
in
(
e
.
srn
for
e
in
manifest_analyzer
.
unprocessed_entities
)
@
pytest
.
mark
.
parametrize
(
"manifest,expected_replaced_srns"
,
[
pytest
.
param
(
[
{
"id"
:
"surrogate-key:wpc"
,
"ref"
:
"surrogate-key:wpc2"
},
{
"id"
:
"surrogate-key:wpc2"
}
],
"system_srn: surrogate-key:wpc2:"
,
id
=
"Surrogate key"
),
pytest
.
param
(
[
{
"id"
:
"surrogate-key:wpc"
,
"ref"
:
"osdu:reference-data--ResourceSecurityClassification:RESTRICTED:test:"
},
{
"id"
:
"osdu:reference-data--ResourceSecurityClassification:RESTRICTED:test"
}
],
"osdu:reference-data--ResourceSecurityClassification:RESTRICTED:test:"
,
id
=
"Real Ids"
)
]
)
def
test_update_parent_srn_with_system_srn
(
self
,
manifest
,
expected_replaced_srns
):
data
=
[
ManifestEntity
(
entity
=
e
,
schema
=
""
)
for
e
in
manifest
]
token_refresher
=
AirflowTokenRefresher
()
manifest_analyzer
=
ManifestAnalyzer
(
data
,
token_refresher
)
for
entity
in
manifest_analyzer
.
entity_queue
():
entity
.
replace_parents_surrogate_srns
()
entity
.
system_srn
=
self
.
process_entity
(
entity
)
if
entity
.
content
.
get
(
"ref"
):
assert
entity
.
content
[
"ref"
]
==
expected_replaced_srns
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment