Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scRNA-seq-simulation
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
zavolan_group
pipelines
scRNA-seq-simulation
Commits
eaaef016
Commit
eaaef016
authored
3 years ago
by
Michele Garioni
Browse files
Options
Downloads
Patches
Plain Diff
fix: add testing for cli
parent
9de5ef24
Branches
Branches containing commit
No related tags found
3 merge requests
!24
Draft: Count gene
,
!21
fix: add cli to sample_from_input
,
!20
Feature
Pipeline
#13789
passed
3 years ago
Stage: qc
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_sampleinput.py
+38
-4
38 additions, 4 deletions
tests/test_sampleinput.py
with
38 additions
and
4 deletions
tests/test_sampleinput.py
+
38
−
4
View file @
eaaef016
...
@@ -2,11 +2,20 @@
...
@@ -2,11 +2,20 @@
import
pytest
import
pytest
import
pandas
as
pd
import
pandas
as
pd
import
os
import
importlib.util
from
pathlib
import
Path
import
sys
from
src.sample_from_input
import
sample_from_input
from
src.sample_from_input
import
(
sample_from_input
,
main
)
PACKAGE_DIR
=
Path
(
__file__
).
resolve
().
parents
[
1
]
/
'
src
'
def
test_sampleinput
(
tmpdir
):
def
test_sample
_from_
input
(
tmpdir
):
"""
Tests the output, input file name and separator.
"""
"""
Tests the output, input file name and separator.
"""
sample_from_input
(
sample_from_input
(
input_file
=
'
./tests/resources/Transcript2.tsv
'
,
input_file
=
'
./tests/resources/Transcript2.tsv
'
,
...
@@ -14,9 +23,34 @@ def test_sampleinput(tmpdir):
...
@@ -14,9 +23,34 @@ def test_sampleinput(tmpdir):
sep
=
'
\t
'
,
sep
=
'
\t
'
,
n
=
142958
n
=
142958
)
)
t1
=
pd
.
read_table
(
tmpdir
/
'
test1.csv
'
,
header
=
None
,
sep
=
'
,
'
)
t1
=
pd
.
read_table
(
tmpdir
/
'
test1.csv
'
,
header
=
None
,
sep
=
'
,
'
)
assert
t1
[
1
].
sum
()
==
142958
assert
t1
[
1
].
sum
()
==
142958
with
pytest
.
raises
(
IndexError
):
with
pytest
.
raises
(
IndexError
):
sample_from_input
(
input_file
=
'
./tests/resources/Transcript2.tsv
'
)
sample_from_input
(
input_file
=
'
./tests/resources/Transcript2.tsv
'
)
with
pytest
.
raises
(
IOError
):
with
pytest
.
raises
(
IOError
):
sample_from_input
(
input_file
=
'
file_not_existing.txt
'
)
sample_from_input
(
input_file
=
'
file_not_existing.txt
'
)
def
test_main_with_args
(
monkeypatch
,
tmpdir
):
"""
Call with args.
"""
monkeypatch
.
setattr
(
sys
,
'
argv
'
,
[
'
sample_from_input
'
,
'
./tests/resources/Transcript1.csv
'
,
'
-o
'
,
str
(
tmpdir
/
'
test1.csv
'
),
]
)
ret_val
=
main
()
assert
ret_val
is
None
def
test_main_as_script
():
"""
Run as script.
"""
main_file
=
PACKAGE_DIR
/
"
sample_from_input.py
"
fl
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
main_file
)
spec
=
importlib
.
util
.
spec_from_file_location
(
'
__main__
'
,
fl
)
module
=
importlib
.
util
.
module_from_spec
(
spec
)
with
pytest
.
raises
(
SystemExit
)
as
exc
:
spec
.
loader
.
exec_module
(
module
)
assert
exc
.
value
.
code
!=
0
\ No newline at end of file
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