Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
0fe58953
Commit
0fe58953
authored
6 years ago
by
Jörn Künsemöller
Browse files
Options
Downloads
Patches
Plain Diff
Task
LSMR-14
: Fixed model tests
parent
c83c8d4c
No related branches found
No related tags found
1 merge request
!87
Lsmr epic
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/LSMR/test/t_lsmrapp_models.py
+44
-20
44 additions, 20 deletions
SAS/LSMR/test/t_lsmrapp_models.py
with
44 additions
and
20 deletions
SAS/LSMR/test/t_lsmrapp_models.py
+
44
−
20
View file @
0fe58953
...
...
@@ -105,20 +105,28 @@ class GeneratorTemplateTest(rest_framework.test.APITransactionTestCase):
for
item
in
self
.
test_data_2
.
items
():
self
.
assertIn
(
item
,
response2
.
data
.
items
())
# todo: find a technical solution how to actually do this first, also implement for the other templates then.
# def test_GeneratorTemplate_prevents_double_default_version_for_same_name(self):
#
# # setup
# test_data_1 = dict(self.test_data_1)
# test_data_2 = dict(self.test_data_2)
# test_data_1['default_version'] = True
# test_data_2['default_version'] = True
# models.GeneratorTemplate.objects.create(**test_data_1)
#
# # assert
# with self.assertRaises(Exception):
# models.GeneratorTemplate.objects.create(**test_data_2)
class
DefaultGeneratorTemplateTest
(
rest_framework
.
test
.
APITransactionTestCase
):
test_data
=
{
'
name
'
:
'
default
'
,
'
template
'
:
None
,
'
tags
'
:[]}
def
test_DefaultGeneratorTemplate_prevents_same_name
(
self
):
templ1
=
models
.
GeneratorTemplate
.
objects
.
create
(
**
GeneratorTemplateTest
.
test_data_1
)
templ2
=
models
.
GeneratorTemplate
.
objects
.
create
(
**
GeneratorTemplateTest
.
test_data_2
)
# setup
test_data_1
=
dict
(
self
.
test_data
)
test_data_2
=
dict
(
self
.
test_data
)
test_data_1
[
'
template
'
]
=
templ1
test_data_2
[
'
template
'
]
=
templ2
models
.
DefaultGeneratorTemplate
.
objects
.
create
(
**
test_data_1
)
# assert
with
self
.
assertRaises
(
Exception
):
models
.
DefaultGeneratorTemplate
.
objects
.
create
(
**
test_data_2
)
class
RunTemplateTest
(
rest_framework
.
test
.
APITransactionTestCase
):
...
...
@@ -361,15 +369,15 @@ class WorkIORoleTest(rest_framework.test.APITransactionTestCase):
self
.
test_data_1
=
{
"
role
"
:
models
.
RoleChoice
.
objects
.
get
(
value
=
'
calibrator
'
),
"
datatype
"
:
models
.
DatatypeChoice
.
objects
.
get
(
value
=
'
instrument model
'
),
"
dataformat
"
:
models
.
DataformatChoice
.
objects
.
get
(
value
=
'
HDF5
'
),
"
outputs
"
:
None
,
"
inputs
"
:
None
,
"
outputs
"
:
models
.
WorkRequestTemplate
.
objects
.
create
(
**
WorkRequestTemplateTest
.
test_data_1
)
,
"
inputs
"
:
models
.
WorkRequestTemplate
.
objects
.
create
(
**
WorkRequestTemplateTest
.
test_data_2
)
,
"
tags
"
:
[]}
self
.
test_data_2
=
{
"
role
"
:
models
.
RoleChoice
.
objects
.
get
(
value
=
'
target
'
),
"
datatype
"
:
models
.
DatatypeChoice
.
objects
.
get
(
value
=
'
image
'
),
"
dataformat
"
:
models
.
DataformatChoice
.
objects
.
get
(
value
=
'
MeasurementSet
'
),
"
outputs
"
:
None
,
"
inputs
"
:
None
,
"
outputs
"
:
models
.
WorkRequestTemplate
.
objects
.
create
(
**
WorkRequestTemplateTest
.
test_data_2
)
,
"
inputs
"
:
models
.
WorkRequestTemplate
.
objects
.
create
(
**
WorkRequestTemplateTest
.
test_data_1
)
,
"
tags
"
:
[]}
def
assertDataWithUrls
(
self
,
data
,
expected
):
...
...
@@ -380,6 +388,8 @@ class WorkIORoleTest(rest_framework.test.APITransactionTestCase):
if
isinstance
(
v
,
models
.
AbstractChoice
):
v
=
v
.
value
.
replace
(
'
'
,
'
%20
'
)
self
.
assertTrue
(
v
in
data
[
k
])
elif
isinstance
(
v
,
models
.
Template
):
self
.
assertTrue
(
str
(
v
.
id
)
in
data
[
k
])
else
:
self
.
assertEqual
(
v
,
data
[
k
])
...
...
@@ -407,11 +417,25 @@ class WorkIORoleTest(rest_framework.test.APITransactionTestCase):
self
.
assertDataWithUrls
(
response1
.
data
,
self
.
test_data_1
)
self
.
assertDataWithUrls
(
response2
.
data
,
self
.
test_data_2
)
def
test_POST_WorkIORole_prevents_missing_inputs
(
self
):
# todo: def test_WorkIORole_prevents_missing_inputs(self):
# setup
test_data_1
=
dict
(
self
.
test_data_1
)
test_data_1
[
'
inputs
'
]
=
None
# assert
with
self
.
assertRaises
(
Exception
):
models
.
WorkIORole
.
objects
.
create
(
test_data_1
)
def
test_POST_WorkIORole_prevents_missing_outputs
(
self
):
# todo: def test_WorkIORole_prevents_missing_outputs(self):
# setup
test_data_1
=
dict
(
self
.
test_data_1
)
test_data_1
[
'
outputs
'
]
=
None
# assert
with
self
.
assertRaises
(
Exception
):
models
.
WorkIORole
.
objects
.
create
(
**
test_data_1
)
# todo: def test_WorkIORole_allows_existing_inputs_and_outputs(self):
# todo: Tags? -> Decide how to deal with them first.
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