Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
plotID_python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plotID
plotID_python
Commits
34ee81df
Commit
34ee81df
authored
2 years ago
by
Mayr, Hannes
Browse files
Options
Downloads
Patches
Plain Diff
Unittest for crashing publish and the cleanup of the partially copied data.
parent
38e88971
No related branches found
No related tags found
1 merge request
!19
merge dev for new release v.0.1.2
Pipeline
#783605
passed
2 years ago
Stage: linting
Stage: testing
Stage: docs
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
plotid/example.py
+1
-1
1 addition, 1 deletion
plotid/example.py
plotid/publish.py
+2
-1
2 additions, 1 deletion
plotid/publish.py
tests/test_publish.py
+9
-4
9 additions, 4 deletions
tests/test_publish.py
with
12 additions
and
6 deletions
plotid/example.py
+
1
−
1
View file @
34ee81df
...
@@ -57,4 +57,4 @@ IMGS_AS_LIST = [IMG1, IMG2]
...
@@ -57,4 +57,4 @@ IMGS_AS_LIST = [IMG1, IMG2]
publish
([
'
../README.md
'
,
'
../docs
'
,
'
../LICENSE
'
],
publish
([
'
../README.md
'
,
'
../docs
'
,
'
../LICENSE
'
],
'
/home/chief/Dokumente/fst/plotid_python/data
'
,
'
/home/chief/Dokumente/fst/plotid_python/data
'
,
TAGGED_FIGS
,
'
Bild
4
'
)
TAGGED_FIGS
,
'
Bild
'
)
This diff is collapsed.
Click to expand it.
plotid/publish.py
+
2
−
1
View file @
34ee81df
...
@@ -164,7 +164,8 @@ class PublishOptions:
...
@@ -164,7 +164,8 @@ class PublishOptions:
'
removed? (yes/no[default])
\n
'
)
'
removed? (yes/no[default])
\n
'
)
if
delete_dir
in
(
'
yes
'
,
'
y
'
):
if
delete_dir
in
(
'
yes
'
,
'
y
'
):
shutil
.
rmtree
(
dst_path_invisible
)
shutil
.
rmtree
(
dst_path_invisible
)
raise
RuntimeError
(
'
Publishing was unsuccessful.
'
)
from
exc
raise
RuntimeError
(
'
Publishing was unsuccessful.
'
'
Try re-running publish.
'
)
from
exc
case
_
:
case
_
:
raise
ValueError
(
f
'
The data storage method
{
self
.
data_storage
}
'
raise
ValueError
(
f
'
The data storage method
{
self
.
data_storage
}
'
'
is not available.
'
)
'
is not available.
'
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_publish.py
+
9
−
4
View file @
34ee81df
...
@@ -175,13 +175,18 @@ class TestPublish(unittest.TestCase):
...
@@ -175,13 +175,18 @@ class TestPublish(unittest.TestCase):
@unittest.skipIf
(
not
os
.
path
.
isfile
(
sys
.
argv
[
0
]),
'
Publish is not called
'
@unittest.skipIf
(
not
os
.
path
.
isfile
(
sys
.
argv
[
0
]),
'
Publish is not called
'
'
from a Python script. Therefore, the script cannot be
'
'
from a Python script. Therefore, the script cannot be
'
'
copied.
'
)
'
copied.
'
)
def
test_dst_
_
invisible_already_exists
(
self
):
def
test_dst_invisible_already_exists
(
self
):
"""
"""
Test if publish succeeds when there is already an invisible
Test if after a crash of publish the partially copied data is
directory from a previous run (delete the folder and proceed).
removed.
To mock this, the invisible directory already exists.
"""
"""
os
.
mkdir
(
INVISIBLE_PATH
)
os
.
mkdir
(
INVISIBLE_PATH
)
# Mock user input as 'yes'
with
patch
(
'
builtins.input
'
,
return_value
=
'
yes
'
):
with
self
.
assertRaises
(
RuntimeError
):
publish
(
SRC_DIR
,
DST_PATH
,
FIG
,
PIC_NAME
,
'
individual
'
)
publish
(
SRC_DIR
,
DST_PATH
,
FIG
,
PIC_NAME
,
'
individual
'
)
assert
not
os
.
path
.
isdir
(
INVISIBLE_PATH
)
def
test_plot_names
(
self
):
def
test_plot_names
(
self
):
"""
Test if Error is raised if plot_name is not a string.
"""
"""
Test if Error is raised if plot_name is not a string.
"""
...
...
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