Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
RuQaD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue 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
caosdb
Software
FAIR Data Spaces
RuQaD
Commits
3aebe406
Verified
Commit
3aebe406
authored
5 months ago
by
Daniel Hornung
Committed by
Timm Fitschen
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Added first test for qualitychecker.
parent
79d5f7f5
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!8
Code coverage
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyproject.toml
+9
-0
9 additions, 0 deletions
pyproject.toml
src/ruqad/qualitycheck.py
+1
-1
1 addition, 1 deletion
src/ruqad/qualitycheck.py
unittests/test_qualitycheck.py
+43
-0
43 additions, 0 deletions
unittests/test_qualitycheck.py
with
53 additions
and
1 deletion
pyproject.toml
+
9
−
0
View file @
3aebe406
...
...
@@ -46,6 +46,7 @@ dev = [
test
=
[
"tox"
,
"pytest"
,
"pytest-env"
,
"pytest-cov"
,
]
all
=
[
...
...
@@ -58,3 +59,11 @@ rq_qualitycheck = "ruqad.qualitycheck:main"
[tool.setuptools.package-data]
ruqad
=
[
"resources/**/*"
]
[tool.pytest.ini_options]
env
=
[
"S3_ACCESS_KEY_ID
=
1234
",
"S3_SECRET_ACCESS_KEY
=
1234
",
"GITLAB_PIPELINE_TOKEN
=
1234
",
"GITLAB_API_TOKEN
=
1234
",
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/ruqad/qualitycheck.py
+
1
−
1
View file @
3aebe406
...
...
@@ -155,7 +155,7 @@ This deletes all the objects in the bucket.
zipf
=
ZipFile
(
filename
)
zipf
.
extractall
(
path
=
tmp
)
# TODO Zip bomb detection and prevention.
for
name
in
zipf
.
namelist
():
if
name
.
endswith
(
"
.json
"
):
if
name
.
endswith
(
"
.json
"
)
or
name
.
endswith
(
os
.
path
.
sep
)
:
continue
if
upload
:
self
.
_upload
(
os
.
path
.
join
(
tmp
,
name
),
remove_prefix
=
tmp
)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_qualitycheck.py
0 → 100644
+
43
−
0
View file @
3aebe406
# Copyright (C) 2024 IndiScale GmbH <info@indiscale.com>
# Copyright (C) 2024 Daniel Hornung <d.hornung@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
Unit tests for the QualityChecker.
"""
from
datetime
import
datetime
from
pathlib
import
Path
from
unittest.mock
import
patch
,
Mock
from
ruqad
import
qualitycheck
@patch
(
"
boto3.Session.client
"
)
def
test_qc_internal
(
mock_s3_client
):
zipfile
=
(
Path
(
__file__
).
parents
[
1
]
/
"
end-to-end-tests
"
/
"
data
"
/
"
crawler_data
"
/
"
ruqad
"
/
"
1223
"
/
"
export.eln
"
)
qc
=
qualitycheck
.
QualityChecker
()
qc
.
_extract_content
(
zipfile
,
upload
=
True
)
correct_call
=
False
for
call
in
mock_s3_client
.
mock_calls
:
if
not
call
[
0
]
==
'
().upload_file
'
:
continue
if
(
len
(
call
.
args
)
==
3
and
call
.
args
[
0
].
endswith
(
"
abalone2.csv
"
)
and
call
.
args
[
1
]
==
"
ruqad
"
and
call
.
args
[
2
]
==
"
data/test-crawler-second/test-crawler-second/files/abalone2.csv
"
):
correct_call
=
True
break
assert
correct_call
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