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
b880f6b9
Commit
b880f6b9
authored
2 years ago
by
Remco Tukker
Browse files
Options
Downloads
Patches
Plain Diff
add testcase for policy endpoint
parent
e5ec92b2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
compendium_v2/routes/policy.py
+1
-1
1 addition, 1 deletion
compendium_v2/routes/policy.py
test/conftest.py
+27
-0
27 additions, 0 deletions
test/conftest.py
test/test_policies.py
+13
-0
13 additions, 0 deletions
test/test_policies.py
with
41 additions
and
1 deletion
compendium_v2/routes/policy.py
+
1
−
1
View file @
b880f6b9
...
...
@@ -32,7 +32,7 @@ POLICY_RESPONSE_SCHEMA = {
},
'
type
'
:
'
array
'
,
'
items
'
:
{
'
$ref
'
:
'
#/definitions/
funding
'
}
'
items
'
:
{
'
$ref
'
:
'
#/definitions/
policy
'
}
}
...
...
This diff is collapsed.
Click to expand it.
test/conftest.py
+
27
−
0
View file @
b880f6b9
...
...
@@ -237,3 +237,30 @@ def test_ec_project_data(app):
db
.
session
.
add
(
model
.
ECProject
(
nren
=
nren
,
year
=
year
,
project
=
project
))
db
.
session
.
commit
()
@pytest.fixture
def
test_policy_data
(
app
):
with
app
.
app_context
():
nrens_and_years
=
[(
'
nren1
'
,
2019
),
(
'
nren1
'
,
2020
),
(
'
nren1
'
,
2021
),
(
'
nren2
'
,
2019
),
(
'
nren2
'
,
2021
)]
nren_names
=
set
(
ny
[
0
]
for
ny
in
nrens_and_years
)
nren_dict
=
{
nren_name
:
model
.
NREN
(
name
=
nren_name
)
for
nren_name
in
nren_names
}
db
.
session
.
add_all
(
nren_dict
.
values
())
for
(
nren_name
,
year
)
in
nrens_and_years
:
nren
=
nren_dict
[
nren_name
]
db
.
session
.
add
(
model
.
Policy
(
nren
=
nren
,
year
=
year
,
strategic_plan
=
'
a strategy
'
,
environmental
=
'
a policy
'
,
equal_opportunity
=
'
another policy
'
,
connectivity
=
''
,
acceptable_use
=
''
,
privacy_notice
=
''
,
data_protection
=
''
))
db
.
session
.
commit
()
This diff is collapsed.
Click to expand it.
test/test_policies.py
0 → 100644
+
13
−
0
View file @
b880f6b9
import
json
import
jsonschema
from
compendium_v2.routes.policy
import
POLICY_RESPONSE_SCHEMA
def
test_ec_project_response
(
client
,
test_policy_data
):
rv
=
client
.
get
(
'
/api/policy/
'
,
headers
=
{
'
Accept
'
:
[
'
application/json
'
]})
assert
rv
.
status_code
==
200
result
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
jsonschema
.
validate
(
result
,
POLICY_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