Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CiS Projekt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ockenden, Samuel
CiS Projekt
Commits
99a9593a
Commit
99a9593a
authored
3 years ago
by
Malte Schokolowski
Browse files
Options
Downloads
Patches
Plain Diff
added unit tests for update_depth.py
parent
53e1eb6f
No related branches found
Branches containing commit
No related tags found
1 merge request
!14
stable version and bug fixes for graph update
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
verarbeitung/test/update_graph_unittest.py
+35
-3
35 additions, 3 deletions
verarbeitung/test/update_graph_unittest.py
verarbeitung/update_graph/update_depth.py
+30
-10
30 additions, 10 deletions
verarbeitung/update_graph/update_depth.py
with
65 additions
and
13 deletions
verarbeitung/test/update_graph_unittest.py
+
35
−
3
View file @
99a9593a
...
...
@@ -9,7 +9,7 @@ from verarbeitung.construct_new_graph.initialize_graph import init_graph_constru
from
verarbeitung.construct_new_graph.export_to_json
import
output_to_json
from
verarbeitung.update_graph.import_from_json
import
input_from_json
from
verarbeitung.update_graph.update_graph
import
update_graph
,
get_old_input_dois
,
get_new_input_dois
from
verarbeitung.update_graph.update_depth
import
reduce_max_height_depth_test
,
get_old_
height_depth
from
verarbeitung.update_graph.update_depth
import
reduce_max_height_depth_test
,
get_old_
max_references_citations_test
from
verarbeitung.get_pub_from_input
import
input_test_func
class
UpdatingTest
(
unittest
.
TestCase
):
...
...
@@ -66,8 +66,8 @@ class UpdatingTest(unittest.TestCase):
# hard to test because we only have dois as test objects and no urls variant
def
test_get_new_input_dois
(
self
):
new_dois
=
[
'
pub
_lg_2_i
'
,
'
pub
_lg_1_i
'
,
'
pub_lg
_c_i
'
]
self
.
assertCountEqual
(
get_new_input_dois
(
new_dois
,
True
),
[
'
pub
_lg_2_i
'
,
'
pub
_lg_1_i
'
,
'
pub_lg
_c_i
'
])
new_dois
=
[
'
doi
_lg_2_i
'
,
'
doi
_lg_1_i
'
,
'
doi
_c
g
_i
'
]
self
.
assertCountEqual
(
get_new_input_dois
(
new_dois
,
True
),
[
'
doi
_lg_2_i
'
,
'
doi
_lg_1_i
'
,
'
doi
_c
g
_i
'
])
# update_depth.py:
...
...
@@ -104,6 +104,38 @@ class UpdatingTest(unittest.TestCase):
self
.
assertCountEqual
(
reduce_max_height_depth_test
(
pubs
,
1
,
"
Depth
"
),
[
pub_lg_2_i
,
pub_lg_2_d_11
,
pub_lg_2_h_11
,
pub_lg_2_h_21
])
self
.
assertCountEqual
(
reduce_max_height_depth_test
(
pubs
,
0
,
"
Depth
"
),
[
pub_lg_2_i
,
pub_lg_2_h_11
,
pub_lg_2_h_21
])
def
test_get_old_max_references
(
self
):
pub_lg_2_i
=
input_test_func
(
'
doi_lg_2_i
'
)
pub_lg_2_i
.
group
=
0
pub_lg_2_h_11
=
input_test_func
(
'
doi_lg_2_h11
'
)
pub_lg_2_h_11
.
group
=
1
pub_lg_2_d_11
=
input_test_func
(
'
doi_lg_2_d11
'
)
pub_lg_2_d_11
.
group
=
-
1
pub_lg_2_h_21
=
input_test_func
(
'
doi_lg_2_h21
'
)
pub_lg_2_h_21
.
group
=
2
pub_lg_2_d_21
=
input_test_func
(
'
doi_lg_2_d21
'
)
pub_lg_2_d_21
.
group
=
-
2
pub_lg_2_d_22
=
input_test_func
(
'
doi_lg_2_d22
'
)
pub_lg_2_d_22
.
group
=
-
2
pubs
=
[
pub_lg_2_i
,
pub_lg_2_h_11
,
pub_lg_2_h_21
,
pub_lg_2_d_11
,
pub_lg_2_d_21
,
pub_lg_2_d_22
]
self
.
assertCountEqual
(
get_old_max_references_citations_test
(
pubs
,
2
,
"
Depth
"
),
[
pub_lg_2_d_21
,
pub_lg_2_d_22
])
def
test_get_old_max_citations
(
self
):
pub_lg_2_i
=
input_test_func
(
'
doi_lg_2_i
'
)
pub_lg_2_i
.
group
=
0
pub_lg_2_h_11
=
input_test_func
(
'
doi_lg_2_h11
'
)
pub_lg_2_h_11
.
group
=
1
pub_lg_2_d_11
=
input_test_func
(
'
doi_lg_2_d11
'
)
pub_lg_2_d_11
.
group
=
-
1
pub_lg_2_h_21
=
input_test_func
(
'
doi_lg_2_h21
'
)
pub_lg_2_h_21
.
group
=
2
pub_lg_2_h_22
=
input_test_func
(
'
doi_lg_2_h22
'
)
pub_lg_2_h_22
.
group
=
2
pub_lg_2_d_21
=
input_test_func
(
'
doi_lg_2_d21
'
)
pub_lg_2_d_21
.
group
=
-
2
pubs
=
[
pub_lg_2_i
,
pub_lg_2_h_11
,
pub_lg_2_h_21
,
pub_lg_2_h_22
,
pub_lg_2_d_11
,
pub_lg_2_d_21
]
self
.
assertCountEqual
(
get_old_max_references_citations_test
(
pubs
,
2
,
"
Height
"
),
[
pub_lg_2_h_21
,
pub_lg_2_h_22
])
...
...
This diff is collapsed.
Click to expand it.
verarbeitung/update_graph/update_depth.py
+
30
−
10
View file @
99a9593a
...
...
@@ -23,28 +23,48 @@ from .update_edges import back_to_valid_edges
from
input.publication
import
Publication
def
reduce_max_height_depth_test
(
pubs
,
max_
hd
,
hd
_var
):
def
reduce_max_height_depth_test
(
pubs
,
max_
dh
,
dh
_var
):
'''
:param pubs: list of publication to reduce height/depth in
:type pubs: List[Publication]
:param max_
h
d: new maximum height
/depth
to reduce publications in publication list to
:type max_
h
d: int
:param max_d
h
: new maximum
depth/
height to reduce publications in publication list to
:type max_d
h
: int
:param
h
d_var: defines if depth or height gets to be reduced
:type
h
d_var: String
:param d
h
_var: defines if depth or height gets to be reduced
:type d
h
_var: String
for unit test purposes only
'''
global
processed_input_list
processed_input_list
=
pubs
if
h
d_var
==
"
Height
"
:
reduce_max_height
(
max_
h
d
)
if
d
h
_var
==
"
Height
"
:
reduce_max_height
(
max_d
h
)
else
:
reduce_max_depth
(
max_
h
d
)
reduce_max_depth
(
max_d
h
)
return
processed_input_list
def
get_old_max_references_citations_test
(
pubs
,
old_dh
,
dh_var
):
'''
:param pubs: list of publication to reduce height/depth in
:type pubs: List[Publication]
:param old_dh: old depth/height to get max references/citations
:type old_dh: int
:param dh_var: defines if depth or height gets to be reduced
:type dh_var: String
for unit test purposes only
'''
global
processed_input_list
processed_input_list
=
pubs
if
dh_var
==
"
Height
"
:
return
(
get_old_max_citations
(
old_dh
,
True
))
else
:
return
(
get_old_max_references
(
old_dh
,
True
))
def
reduce_max_height
(
max_height
):
'''
...
...
@@ -96,7 +116,7 @@ def get_old_max_references(old_depth, test_var):
'''
old_max_references
=
[]
for
pub
in
processed_input_list
:
if
(
abs
(
pub
.
group
)
==
old_depth
):
if
(
pub
.
group
==
-
old_depth
):
pub
=
get_pub
(
pub
.
doi_url
,
test_var
)
if
(
type
(
pub
)
!=
Publication
):
#print(pub)
...
...
@@ -113,7 +133,7 @@ def get_old_max_citations(old_height, test_var):
'''
old_max_citations
=
[]
for
pub
in
processed_input_list
:
if
(
abs
(
pub
.
group
)
==
old_height
):
if
(
pub
.
group
==
old_height
):
pub
=
get_pub
(
pub
.
doi_url
,
test_var
)
if
(
type
(
pub
)
!=
Publication
):
#print(pub)
...
...
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