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
e9eee39f
Commit
e9eee39f
authored
2 years ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
add tests
parent
0dd3f077
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/conftest.py
+59
-0
59 additions, 0 deletions
test/conftest.py
test/test_organization.py
+22
-0
22 additions, 0 deletions
test/test_organization.py
with
81 additions
and
0 deletions
test/conftest.py
+
59
−
0
View file @
e9eee39f
...
...
@@ -227,3 +227,62 @@ def test_charging_structure_data():
nren
=
nren
,
year
=
year
,
fee_type
=
fee_type
)
)
@pytest.fixture
def
test_organization_data
():
def
_generate_sub_org_data
():
for
nren
in
[
"
nren
"
+
str
(
i
)
for
i
in
range
(
1
,
50
)]:
for
year
in
range
(
2016
,
2021
):
yield
{
'
nren
'
:
nren
,
'
year
'
:
year
,
'
name
'
:
'
sub_org
'
+
str
(
random
.
randint
(
1
,
100
)),
'
role
'
:
random
.
choice
([
'
technical centre
'
,
'
stuff
'
,
'
test123
'
]),
}
def
_generate_org_data
():
for
nren
in
[
"
nren
"
+
str
(
i
)
for
i
in
range
(
1
,
50
)]:
for
year
in
range
(
2016
,
2021
):
yield
{
'
nren
'
:
nren
,
'
year
'
:
year
,
'
name
'
:
'
org
'
+
str
(
year
)
}
with
db
.
session_scope
()
as
session
:
org_data
=
list
(
_generate_org_data
())
sub_org_data
=
list
(
_generate_sub_org_data
())
nren_dict
=
{
nren_name
:
model
.
NREN
(
name
=
nren_name
)
for
nren_name
in
set
(
d
[
'
nren
'
]
for
d
in
[
*
org_data
,
*
sub_org_data
])}
session
.
add_all
(
nren_dict
.
values
())
for
org
in
org_data
:
nren
=
nren_dict
[
org
[
"
nren
"
]]
year
=
org
[
"
year
"
]
name
=
org
[
"
name
"
]
session
.
add
(
model
.
ParentOrganization
(
nren
=
nren
,
year
=
year
,
organization
=
name
)
)
for
sub_org
in
sub_org_data
:
nren
=
nren_dict
[
sub_org
[
"
nren
"
]]
year
=
sub_org
[
"
year
"
]
name
=
sub_org
[
"
name
"
]
role
=
sub_org
[
"
role
"
]
session
.
add
(
model
.
SubOrganization
(
nren
=
nren
,
year
=
year
,
organization
=
name
,
role
=
role
)
)
session
.
commit
()
This diff is collapsed.
Click to expand it.
test/test_organization.py
0 → 100644
+
22
−
0
View file @
e9eee39f
import
json
import
jsonschema
from
compendium_v2.routes.organization
import
ORGANIZATION_RESPONSE_SCHEMA
def
test_parentorganization_response
(
client
,
test_organization_data
):
rv
=
client
.
get
(
'
/api/organization/parent
'
,
headers
=
{
'
Accept
'
:
[
'
application/json
'
]})
assert
rv
.
status_code
==
200
result
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
jsonschema
.
validate
(
result
,
ORGANIZATION_RESPONSE_SCHEMA
)
assert
result
def
test_suborganization_response
(
client
,
test_organization_data
):
rv
=
client
.
get
(
'
/api/organization/sub
'
,
headers
=
{
'
Accept
'
:
[
'
application/json
'
]})
assert
rv
.
status_code
==
200
result
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
jsonschema
.
validate
(
result
,
ORGANIZATION_RESPONSE_SCHEMA
)
assert
result
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