Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Airflow Datacat Integration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eFlows4HPC WP2
Airflow Datacat Integration
Commits
09ccc509
Commit
09ccc509
authored
3 years ago
by
Christian Boettcher
Browse files
Options
Downloads
Patches
Plain Diff
add basic test for uuid validation
parent
60826e03
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#98077
passed
3 years ago
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/datacat_integration/secrets.py
+2
-2
2 additions, 2 deletions
src/datacat_integration/secrets.py
tests/test_secrets.py
+5
-1
5 additions, 1 deletion
tests/test_secrets.py
with
7 additions
and
3 deletions
src/datacat_integration/secrets.py
+
2
−
2
View file @
09ccc509
...
@@ -12,10 +12,10 @@ connection_backend_type = "airflow_connections"
...
@@ -12,10 +12,10 @@ connection_backend_type = "airflow_connections"
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
def
validate_uuid
(
uuid_to_test
:
str
,
version
=
4
):
def
validate_uuid
(
uuid_to_test
:
str
):
"""
Check if uuid_to_test id a valid UUID. Returns True if it is and false if it is not.
"""
"""
Check if uuid_to_test id a valid UUID. Returns True if it is and false if it is not.
"""
try
:
try
:
uuid_obj
=
uuid
.
UUID
(
uuid_to_test
,
version
=
version
)
uuid_obj
=
uuid
.
UUID
(
uuid_to_test
)
except
ValueError
:
except
ValueError
:
return
False
return
False
return
str
(
uuid_obj
)
==
uuid_to_test
return
str
(
uuid_obj
)
==
uuid_to_test
...
...
This diff is collapsed.
Click to expand it.
tests/test_secrets.py
+
5
−
1
View file @
09ccc509
from
unittest
import
TestCase
from
unittest
import
TestCase
import
os
,
json
import
os
,
json
import
uuid
from
dotenv
import
load_dotenv
from
dotenv
import
load_dotenv
from
datacat_integration.secrets
import
DataCatConnectionWithSecrets
,
get_connection_with_secrets_from_entry
,
DatacatSecretsBackend
from
datacat_integration.secrets
import
DataCatConnectionWithSecrets
,
get_connection_with_secrets_from_entry
,
DatacatSecretsBackend
,
validate_uuid
class
TestSecretsBackend
(
TestCase
):
class
TestSecretsBackend
(
TestCase
):
...
@@ -26,6 +27,9 @@ class TestSecretsBackend(TestCase):
...
@@ -26,6 +27,9 @@ class TestSecretsBackend(TestCase):
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_public_extra
'
],
"
12345
"
)
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_public_extra
'
],
"
12345
"
)
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_other_extra_to_be_overwritten_by_secret
'
],
"
secret_67890
"
)
self
.
assertEqual
(
conn
.
extra_dejson
[
'
some_other_extra_to_be_overwritten_by_secret
'
],
"
secret_67890
"
)
def
test_uuid_validation
(
self
):
self
.
assertTrue
(
validate_uuid
(
str
(
uuid
.
uuid4
())))
self
.
assertFalse
(
validate_uuid
(
"
wrong_uuid
"
))
def
test_no_error_on_missing_extra
(
self
):
def
test_no_error_on_missing_extra
(
self
):
get_connection_with_secrets_from_entry
({
"
name
"
:
"
some-name
"
,
"
url
"
:
"
some_url
"
,
"
metadata
"
:
{}},
{},
"
test-connection
"
,
'
false_oid
'
)
get_connection_with_secrets_from_entry
({
"
name
"
:
"
some-name
"
,
"
url
"
:
"
some_url
"
,
"
metadata
"
:
{}},
{},
"
test-connection
"
,
'
false_oid
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment