Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpsd-software-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
MPSD Computational Science
mpsd-software-manager
Commits
73e42262
Commit
73e42262
authored
1 year ago
by
Ashwin Kumar Karnad
Browse files
Options
Downloads
Patches
Plain Diff
add test for prepare_env
parent
d0a3408b
No related branches found
Branches containing commit
No related tags found
2 merge requests
!19
Move linux-debian11 into main
,
!1
Resolve "First draft for user interface for top level install command"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests.py
+24
-1
24 additions, 1 deletion
tests.py
with
24 additions
and
1 deletion
tests.py
+
24
−
1
View file @
73e42262
import
os
import
pytest
import
importlib
import
subprocess
mod
=
importlib
.
import_module
(
"
install-mpsd-software-environment
"
)
def
test_os_chdir
():
# create a temporary directory for testing
temp_dir
=
"
/tmp/test_os_chdir
"
os
.
mkdir
(
temp_dir
)
# initial current working directory
initial_cwd
=
os
.
getcwd
()
...
...
@@ -20,3 +22,24 @@ def test_os_chdir():
# clean up the temporary directory
os
.
rmdir
(
temp_dir
)
def
test_prepare_env
():
# simulate running ./install-software-environment.py --release dev-23a --target-directory /tmp/test_prepare_env
mod
.
prepare_env
(
"
dev-23a
"
,
"
/tmp/test_prepare_env
"
,
False
)
# check if the directory exists
assert
os
.
path
.
exists
(
"
/tmp/test_prepare_env
"
)
# check for spack-environments directory
assert
os
.
listdir
(
"
/tmp/test_prepare_env
"
)
==
[
"
spack-environments
"
]
# check if the git branch is correctl checked out
assert
(
subprocess
.
run
(
"
cd /tmp/test_prepare_env/spack-environments && git branch
"
,
shell
=
True
,
capture_output
=
True
,
).
stdout
.
decode
(
"
utf-8
"
)
==
"
* dev-23a
\n
"
)
# make sure running the command again raises ValueError
with
pytest
.
raises
(
ValueError
):
mod
.
prepare_env
(
"
dev-23a
"
,
"
/tmp/test_prepare_env
"
,
False
)
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