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
8c2b856e
Commit
8c2b856e
authored
3 years ago
by
Melvin Alappat
Browse files
Options
Downloads
Patches
Plain Diff
added: tests for priming_prob.py and CLI
parent
56a52990
Branches
Branches containing commit
No related tags found
1 merge request
!16
Issue_4
Pipeline
#13862
failed
3 years ago
Stage: qc
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_cli_priming_prob.py
+39
-0
39 additions, 0 deletions
tests/test_cli_priming_prob.py
tests/test_priming_prob.py
+35
-0
35 additions, 0 deletions
tests/test_priming_prob.py
with
74 additions
and
0 deletions
tests/test_cli_priming_prob.py
0 → 100644
+
39
−
0
View file @
8c2b856e
"""
Unit tests for module ``CLI_PrimingProb.py``.
"""
import
pytest
from
pathlib
import
Path
from
src.primingprob
import
cli_priming_prob
as
CPb
from
unittest.mock
import
patch
,
MagicMock
PACKAGE_DIR
=
Path
(
__file__
).
resolve
().
parents
[
1
]
TEST_FILE
=
"
./tests/resources/Energies_test.txt
"
class
TestParseArgs
:
"""
Test ``parse_args()`` function.
"""
def
test_no_positional_args
(
self
):
"""
Call without positional args.
"""
with
pytest
.
raises
(
SystemExit
)
as
exc
:
CPb
.
parse_args
()
assert
exc
.
value
.
code
!=
0
class
TestMain
:
"""
Test ``main()`` function.
"""
def
test_without_args
(
self
):
"""
Call without args.
"""
with
pytest
.
raises
(
SystemExit
)
as
exc
:
CPb
.
main
()
assert
exc
.
value
.
code
!=
0
def
test_last_line
(
self
):
"""
Test name equals main.
"""
# Arrange
with
patch
.
object
(
CPb
,
"
main
"
,
MagicMock
())
as
mock_main
:
with
patch
.
object
(
CPb
,
"
__name__
"
,
"
__main__
"
):
# Act
CPb
.
init
()
# Assert
mock_main
.
assert_called_once
()
This diff is collapsed.
Click to expand it.
tests/test_priming_prob.py
0 → 100644
+
35
−
0
View file @
8c2b856e
"""
Unit tests for module ``PrimingProb_CI``.
"""
import
os
from
src.primingprob.priming_prob
import
Probability
as
Pbt
Energy_file
=
"
./tests/resources/Energies_test.txt
"
Fasta_file
=
"
./tests/resources/transcript.fasta
"
Output_file
=
"
./tests/resources/Potential_Priming_Sites.txt
"
def
test_inter_para
():
"""
Tests InterPara function.
"""
testdata
=
Pbt
.
inter_para
(
Energy_file
)
assert
len
(
testdata
)
==
3
# Number of interactions
assert
type
(
testdata
)
is
list
for
i
in
range
(
0
,
len
(
testdata
)):
assert
testdata
[
i
][
0
].
isdigit
()
return
testdata
testdata2
=
test_inter_para
()
def
test_inter_prob
():
"""
Tests InterProb function.
"""
Pbt
.
inter_prob
(
testdata2
,
Fasta_file
,
Output_file
)
assert
os
.
path
.
exists
(
Output_file
)
is
True
# Check whether file exists
mytestfile
=
open
(
Output_file
,
"
r
"
)
# Test whether gff file start with transcript ID
for
mylinecounter
in
mytestfile
:
assert
mylinecounter
.
startswith
(
"
NW_005196756.1:c68260-66684
"
)
with
open
(
Output_file
,
"
r
"
)
as
tt
:
# Check whether number of interactions is right
x
=
len
(
tt
.
readlines
())
assert
x
==
3
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