Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compendium-v2
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
geant-swd
compendium-v2
Commits
5a68a352
Commit
5a68a352
authored
2 years ago
by
Remco Tukker
Browse files
Options
Downloads
Patches
Plain Diff
added unittests for conversion
parent
f5deacac
No related branches found
No related tags found
1 merge request
!47
Feature/comp 218 migrating 2022 data
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_conversion.py
+68
-0
68 additions, 0 deletions
test/test_conversion.py
with
68 additions
and
0 deletions
test/test_conversion.py
0 → 100644
+
68
−
0
View file @
5a68a352
from
sqlalchemy
import
select
from
compendium_v2.db
import
db
from
compendium_v2.db.model
import
NREN
from
compendium_v2.db.survey_model
import
Survey
,
SurveyResponse
from
compendium_v2.conversion.conversion
import
_cli
,
convert_answers
def
mock_convert_answers
(
_
):
return
{
"
data
"
:
{}}
def
mock_query_nren
(
_
):
return
{
16455
:
"
answer1
"
}
def
test_queries
(
app_with_survey_db
,
mocker
):
with
app_with_survey_db
.
app_context
():
db
.
session
.
add
(
NREN
(
name
=
'
Restena
'
,
country
=
'
country
'
))
db
.
session
.
commit
()
mocker
.
patch
(
'
compendium_v2.conversion.conversion.convert_answers
'
,
mock_convert_answers
)
mocker
.
patch
(
'
compendium_v2.conversion.conversion.query_nren
'
,
mock_query_nren
)
_cli
(
app_with_survey_db
)
with
app_with_survey_db
.
app_context
():
surveys
=
db
.
session
.
scalars
(
select
(
Survey
)).
all
()
assert
len
(
surveys
)
==
1
assert
surveys
[
0
].
year
==
2022
responses
=
db
.
session
.
scalars
(
select
(
SurveyResponse
).
order_by
(
SurveyResponse
.
nren_id
)).
all
()
assert
len
(
responses
)
==
1
assert
responses
[
0
].
answers
==
{
"
data
"
:
{}}
def
test_conversion
():
answers
=
{
16455
:
'"
full nren name
"'
,
16453
:
'
[
"
ec project1
"
,
"
ec project2
"
]
'
,
16632
:
'"
3434
"'
,
16432
:
'"
suborg name 3
"'
,
16410
:
'"
We use a combination of flat fee and usage-based fee
"'
,
16474
:
'"
Yes
"'
,
16476
:
'"
No
"'
,
16491
:
'
[
"
Universities
"
,
"
Further education
"
]
'
,
16492
:
'
[
"
Research institutes
"
,
"
Universities
"
]
'
}
converted_answers
=
convert_answers
(
answers
)
assert
converted_answers
==
{
'
data
'
:
{
'
charging_mechanism
'
:
'
combination
'
,
'
suborganization_details
'
:
[{},
{},
{},
{
'
suborganization_name
'
:
'
suborg name 3
'
}],
'
ec_project_names
'
:
[{
'
ec_project_name
'
:
'
ec project1
'
},
{
'
ec_project_name
'
:
'
ec project2
'
}],
'
full_name_english
'
:
'
full nren name
'
,
'
policies
'
:
{
'
connectivity_policy
'
:
{
'
available
'
:
[
'
yes
'
]},
'
acceptable_use_policy
'
:
{}},
'
traffic_load
'
:
{
'
iros
'
:
{
'
peak_to_institutions_from_network
'
:
'
3434
'
}},
'
service_matrix
'
:
{
'
universities
'
:
{
'
service_types
'
:
[
'
security
'
,
'
isp_support
'
]},
'
further_education
'
:
{
'
service_types
'
:
[
'
security
'
]},
'
institutes
'
:
{
'
service_types
'
:
[
'
isp_support
'
]}
}
}
}
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