Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
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
ots
hypha
Commits
de648f9b
Commit
de648f9b
authored
6 years ago
by
Dan Braghis
Browse files
Options
Downloads
Patches
Plain Diff
Improve tests
parent
8bb1da21
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
opentech/apply/determinations/forms.py
+3
-6
3 additions, 6 deletions
opentech/apply/determinations/forms.py
opentech/apply/determinations/tests/test_views.py
+15
-6
15 additions, 6 deletions
opentech/apply/determinations/tests/test_views.py
with
18 additions
and
12 deletions
opentech/apply/determinations/forms.py
+
3
−
6
View file @
de648f9b
...
...
@@ -55,12 +55,8 @@ class BaseDeterminationForm(forms.ModelForm):
cleaned_data
=
super
().
clean
()
if
self
.
draft_button_name
not
in
self
.
data
:
try
:
outcome
=
int
(
cleaned_data
[
'
outcome
'
])
except
KeyError
:
outcome
=
-
1
action_name
=
self
.
request
.
GET
.
get
(
'
action
'
)
or
self
.
get_action_name_from_determination
(
outcome
)
action_name
=
self
.
request
.
GET
.
get
(
'
action
'
)
or
\
self
.
get_action_name_from_determination
(
int
(
cleaned_data
[
'
outcome
'
]))
if
action_name
:
transition
=
self
.
submission
.
get_transition
(
action_name
)
if
not
can_proceed
(
transition
):
...
...
@@ -83,6 +79,7 @@ class BaseDeterminationForm(forms.ModelForm):
self
.
instance
.
validate_unique
()
except
ValidationError
as
e
:
self
.
_update_errors
(
e
)
def
save
(
self
,
commit
=
True
):
self
.
instance
.
outcome
=
int
(
self
.
cleaned_data
[
'
outcome
'
])
self
.
instance
.
message
=
self
.
cleaned_data
[
'
message
'
]
...
...
This diff is collapsed.
Click to expand it.
opentech/apply/determinations/tests/test_views.py
+
15
−
6
View file @
de648f9b
from
django.test
import
TestCase
,
RequestFactory
from
django.urls
import
reverse
from
opentech.apply.determinations.models
import
ACCEPTED
from
opentech.apply.users.tests.factories
import
StaffFactory
,
UserFactory
from
.factories
import
DeterminationFactory
from
opentech.apply.funds.tests.factories
import
ApplicationSubmissionFactory
...
...
@@ -82,21 +83,29 @@ class DeterminationFormTestCase(BaseTestCase):
def
test_cant_resubmit_determination
(
self
):
submission
=
ApplicationSubmissionFactory
(
status
=
'
in_discussion
'
,
lead
=
self
.
user
)
determination
=
DeterminationFactory
(
submission
=
submission
,
author
=
self
.
user
,
submitted
=
True
)
response
=
self
.
post_page
(
submission
,
{
'
data
'
:
'
value
'
,
'
determination
'
:
determination
.
outcome
},
'
form
'
)
response
=
self
.
post_page
(
submission
,
{
'
data
'
:
'
value
'
,
'
outcome
'
:
determination
.
outcome
},
'
form
'
)
self
.
assertTrue
(
response
.
context
[
'
has_determination_response
'
])
self
.
assertContains
(
response
,
'
You have already added a determination for this submission
'
)
def
test_can_edit_draft_determination
(
self
):
submission
=
ApplicationSubmissionFactory
(
status
=
'
in_discussion
'
,
lead
=
self
.
user
)
determination
=
DeterminationFactory
(
submission
=
submission
,
author
=
self
.
user
)
response
=
self
.
post_page
(
submission
,
{
'
data
'
:
'
value
'
,
'
determination
'
:
determination
.
outcome
},
'
form
'
)
self
.
assertFalse
(
response
.
context
[
'
has_determination_response
'
])
self
.
assertEqual
(
response
.
context
[
'
title
'
],
'
Update Determination draft
'
)
DeterminationFactory
(
submission
=
submission
,
author
=
self
.
user
)
response
=
self
.
post_page
(
submission
,
{
'
data
'
:
'
value
'
,
'
outcome
'
:
ACCEPTED
,
'
message
'
:
'
Accepted determination draft message
'
,
'
save_draft
'
:
True
},
'
form
'
)
self
.
assertContains
(
response
,
'
Accepted
'
)
self
.
assertContains
(
response
,
reverse
(
self
.
url_name
.
format
(
'
form
'
),
kwargs
=
self
.
get_kwargs
(
submission
)))
self
.
assertContains
(
response
,
'
Accepted determination draft message
'
)
def
test_cannot_edit_draft_determination_if_not_lead
(
self
):
submission
=
ApplicationSubmissionFactory
(
status
=
'
in_discussion
'
)
determination
=
DeterminationFactory
(
submission
=
submission
,
author
=
self
.
user
)
response
=
self
.
post_page
(
submission
,
{
'
data
'
:
'
value
'
,
'
determination
'
:
determination
.
outcome
},
'
form
'
)
response
=
self
.
post_page
(
submission
,
{
'
data
'
:
'
value
'
,
'
outcome
'
:
determination
.
outcome
},
'
form
'
)
self
.
assertEqual
(
response
.
status_code
,
403
)
...
...
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