Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
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
Container registry
Model registry
Operate
Environments
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
esde
machine-learning
MLAir
Commits
2f965d0a
Commit
2f965d0a
authored
5 years ago
by
Felix Kleinert
Browse files
Options
Downloads
Patches
Plain Diff
split test_error_handling for
#80
parent
cfdfb51c
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!90
WIP: new release update
,
!89
Resolve "release branch / CI on gpu"
,
!84
Felix issue080 testing test helpers
Pipeline
#32841
passed
5 years ago
Stage: test
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_helpers.py
+16
-17
16 additions, 17 deletions
test/test_helpers.py
with
16 additions
and
17 deletions
test/test_helpers.py
+
16
−
17
View file @
2f965d0a
...
@@ -135,39 +135,38 @@ class TestPrepareHost:
...
@@ -135,39 +135,38 @@ class TestPrepareHost:
@mock.patch
(
"
os.getlogin
"
,
return_value
=
"
testUser
"
)
@mock.patch
(
"
os.getlogin
"
,
return_value
=
"
testUser
"
)
@mock.patch
(
"
os.path.exists
"
,
return_value
=
True
)
@mock.patch
(
"
os.path.exists
"
,
return_value
=
True
)
def
test_prepare_host
(
self
,
mock_host
,
mock_user
,
mock_path
):
def
test_prepare_host
(
self
,
mock_host
,
mock_user
,
mock_path
):
path
=
prepare_host
()
assert
prepare_host
()
==
"
/home/testUser/machinelearningtools/data/toar_daily/
"
assert
path
==
"
/home/testUser/machinelearningtools/data/toar_daily/
"
assert
prepare_host
()
==
"
/home/testUser/Data/toar_daily/
"
path
=
prepare_host
()
assert
prepare_host
()
==
"
/home/testUser/Data/toar_daily/
"
assert
path
==
"
/home/testUser/Data/toar_daily/
"
assert
prepare_host
()
==
"
/p/project/cjjsc42/testUser/DATA/toar_daily/
"
path
=
prepare_host
()
assert
prepare_host
()
==
"
/p/home/jusers/testUser/juwels/intelliaq/DATA/toar_daily/
"
assert
path
==
"
/home/testUser/Data/toar_daily/
"
assert
prepare_host
()
==
'
/home/testUser/machinelearningtools/data/toar_daily/
'
path
=
prepare_host
()
assert
path
==
"
/p/project/cjjsc42/testUser/DATA/toar_daily/
"
path
=
prepare_host
()
assert
path
==
"
/p/home/jusers/testUser/juwels/intelliaq/DATA/toar_daily/
"
path
=
prepare_host
()
assert
path
==
'
/home/testUser/machinelearningtools/data/toar_daily/
'
@mock.patch
(
"
socket.gethostname
"
,
return_value
=
"
NotExistingHostName
"
)
@mock.patch
(
"
socket.gethostname
"
,
return_value
=
"
NotExistingHostName
"
)
@mock.patch
(
"
os.getlogin
"
,
return_value
=
"
zombie21
"
)
@mock.patch
(
"
os.getlogin
"
,
return_value
=
"
zombie21
"
)
def
test_error_handling
(
self
,
mock_user
,
mock_host
):
def
test_error_handling
_unknown_host
(
self
,
mock_user
,
mock_host
):
with
pytest
.
raises
(
OSError
)
as
e
:
with
pytest
.
raises
(
OSError
)
as
e
:
prepare_host
()
prepare_host
()
assert
"
unknown host
'
NotExistingHostName
'"
in
e
.
value
.
args
[
0
]
assert
"
unknown host
'
NotExistingHostName
'"
in
e
.
value
.
args
[
0
]
@mock.patch
(
"
os.getlogin
"
,
return_value
=
"
zombie21
"
)
@mock.patch
(
"
src.helpers.check_path_and_create
"
,
side_effect
=
PermissionError
)
def
test_error_handling
(
self
,
mock_cpath
,
mock_user
):
# if "runner-6HmDp9Qd-project-2411-concurrent" not in platform.node():
# if "runner-6HmDp9Qd-project-2411-concurrent" not in platform.node():
mock_host
.
return_value
=
"
linux-aa9b
"
#
mock_host.return_value = "linux-aa9b"
with
pytest
.
raises
(
NotADirectoryError
)
as
e
:
with
pytest
.
raises
(
NotADirectoryError
)
as
e
:
prepare_host
()
prepare_host
()
assert
"
does not exist for host
'
linux-aa9b
'"
in
e
.
value
.
args
[
0
]
assert
PyTestRegex
(
r
"
path
'
.*
'
does not exist for host
'
.*
'
\.
"
)
==
e
.
value
.
args
[
0
]
with
pytest
.
raises
(
NotADirectoryError
)
as
e
:
with
pytest
.
raises
(
NotADirectoryError
)
as
e
:
prepare_host
(
False
)
prepare_host
(
False
)
assert
"
does not exist for host
'
linux-aa9b
'"
in
e
.
value
.
args
[
0
]
# assert "does not exist for host 'linux-aa9b'" in e.value.args[0]
assert
PyTestRegex
(
r
"
path
'
.*
'
does not exist for host
'
.*
'
\.
"
)
==
e
.
value
.
args
[
0
]
@mock.patch
(
"
socket.gethostname
"
,
side_effect
=
[
"
linux-aa9b
"
,
"
ZAM144
"
,
"
zam347
"
,
"
jrtest
"
,
"
jwtest
"
,
@mock.patch
(
"
socket.gethostname
"
,
side_effect
=
[
"
linux-aa9b
"
,
"
ZAM144
"
,
"
zam347
"
,
"
jrtest
"
,
"
jwtest
"
,
"
runner-6HmDp9Qd-project-2411-concurrent
"
])
"
runner-6HmDp9Qd-project-2411-concurrent
"
])
@mock.patch
(
"
os.getlogin
"
,
side_effect
=
OSError
)
@mock.patch
(
"
os.getlogin
"
,
side_effect
=
OSError
)
@mock.patch
(
"
os.path.exists
"
,
return_value
=
True
)
@mock.patch
(
"
os.path.exists
"
,
return_value
=
True
)
def
test_os_error
(
self
,
mock_
host
,
mock_user
,
mock_
path
):
def
test_os_error
(
self
,
mock_
path
,
mock_user
,
mock_
host
):
path
=
prepare_host
()
path
=
prepare_host
()
assert
path
==
"
/home/default/machinelearningtools/data/toar_daily/
"
assert
path
==
"
/home/default/machinelearningtools/data/toar_daily/
"
path
=
prepare_host
()
path
=
prepare_host
()
...
...
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