Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
ccc933a2
Commit
ccc933a2
authored
Jun 02, 2016
by
Enrico Zini
Browse files
Started testing requirements show pages
parent
9b659142
Changes
6
Hide whitespace changes
Inline
Side-by-side
backend/unittest.py
View file @
ccc933a2
...
@@ -4,7 +4,7 @@ from __future__ import absolute_import
...
@@ -4,7 +4,7 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
division
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
backend.models
as
bmodels
import
backend.models
as
bmodels
from
backend.models
import
Person
,
Process
,
AM
from
backend.models
import
Person
,
Process
,
AM
,
Fingerprint
from
backend
import
const
from
backend
import
const
from
django.utils.timezone
import
now
from
django.utils.timezone
import
now
from
django.test
import
Client
from
django.test
import
Client
...
@@ -216,6 +216,7 @@ class BaseFixtureMixin(TestBase):
...
@@ -216,6 +216,7 @@ class BaseFixtureMixin(TestBase):
super
(
BaseFixtureMixin
,
cls
).
setUpClass
()
super
(
BaseFixtureMixin
,
cls
).
setUpClass
()
cls
.
persons
=
TestPersons
(
**
cls
.
get_persons_defaults
())
cls
.
persons
=
TestPersons
(
**
cls
.
get_persons_defaults
())
cls
.
ams
=
NamedObjects
(
AM
)
cls
.
ams
=
NamedObjects
(
AM
)
cls
.
fingerprints
=
NamedObjects
(
Fingerprint
)
cls
.
keys
=
TestKeys
()
cls
.
keys
=
TestKeys
()
# Preload two keys
# Preload two keys
...
@@ -226,6 +227,7 @@ class BaseFixtureMixin(TestBase):
...
@@ -226,6 +227,7 @@ class BaseFixtureMixin(TestBase):
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
cls
.
keys
.
delete_all
()
cls
.
keys
.
delete_all
()
cls
.
ams
.
delete_all
()
cls
.
ams
.
delete_all
()
cls
.
fingerprints
.
delete_all
()
cls
.
persons
.
delete_all
()
cls
.
persons
.
delete_all
()
super
(
BaseFixtureMixin
,
cls
).
tearDownClass
()
super
(
BaseFixtureMixin
,
cls
).
tearDownClass
()
...
@@ -233,6 +235,7 @@ class BaseFixtureMixin(TestBase):
...
@@ -233,6 +235,7 @@ class BaseFixtureMixin(TestBase):
super
(
BaseFixtureMixin
,
self
).
setUp
()
super
(
BaseFixtureMixin
,
self
).
setUp
()
self
.
persons
.
refresh
();
self
.
persons
.
refresh
();
self
.
ams
.
refresh
();
self
.
ams
.
refresh
();
self
.
fingerprints
.
refresh
();
self
.
keys
.
refresh
();
self
.
keys
.
refresh
();
...
@@ -455,6 +458,11 @@ class PageElements(dict):
...
@@ -455,6 +458,11 @@ class PageElements(dict):
def
add_string
(
self
,
name
,
term
):
def
add_string
(
self
,
name
,
term
):
self
[
name
]
=
re
.
compile
(
r
"""{}"""
.
format
(
re
.
escape
(
term
)))
self
[
name
]
=
re
.
compile
(
r
"""{}"""
.
format
(
re
.
escape
(
term
)))
def
clone
(
self
):
res
=
PageElements
()
res
.
update
(
self
.
items
())
return
res
class
TestOldProcesses
(
NamedObjects
):
class
TestOldProcesses
(
NamedObjects
):
def
__init__
(
self
,
**
defaults
):
def
__init__
(
self
,
**
defaults
):
...
...
process/templates/process/req_am_ok.html
View file @
ccc933a2
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
<td>
{{a.unassigned_time|date:"Y-m-d"}}
</a></td>
<td>
{{a.unassigned_time|date:"Y-m-d"}}
</a></td>
<td>
<td>
{% if not a.unassigned_by %}
{% if not a.unassigned_by %}
<form
action=
"{% url 'process_unassign_am' pk=process.pk %}"
method=
"POST"
>
{% csrf_token %}
<form
id=
"am_unassign"
action=
"{% url 'process_unassign_am' pk=process.pk %}"
method=
"POST"
>
{% csrf_token %}
<button
type=
"submit"
>
Unassign
</button>
<button
type=
"submit"
>
Unassign
</button>
</form>
</form>
{% endif %}
{% endif %}
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
{% endfor %}
{% endfor %}
</tbody>
</tbody>
{% if not process.current_am_assignment %}
{% if not process.current_am_assignment %}
<tfoot>
<tfoot
id=
"am_assign"
>
<tr><td
colspan=
"6"
><a
href=
"{% url 'process_assign_am' pk=process.pk %}"
>
Assign AM
</a></td></tr>
<tr><td
colspan=
"6"
><a
href=
"{% url 'process_assign_am' pk=process.pk %}"
>
Assign AM
</a></td></tr>
</tfoot>
</tfoot>
{% endif %}
{% endif %}
...
...
process/templates/process/statement_table_widget.html
View file @
ccc933a2
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<td>
<td>
<a
href=
"{% url 'process_statement_raw' pk=process.pk type=requirement.type st=s.pk %}"
>
[view raw]
</a>
<a
href=
"{% url 'process_statement_raw' pk=process.pk type=requirement.type st=s.pk %}"
>
[view raw]
</a>
{% if "edit_statements" in visit_perms %}
{% if "edit_statements" in visit_perms %}
<a
href=
"{% url 'process_statement_delete' pk=process.pk type=requirement.type st=s.pk %}"
>
[delete]
</a>
<a
class=
"statement_delete"
href=
"{% url 'process_statement_delete' pk=process.pk type=requirement.type st=s.pk %}"
>
[delete]
</a>
{% endif %}
{% endif %}
</td>
</td>
</tr>
</tr>
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
<tfoot>
<tfoot>
<tr>
<tr>
<td
colspan=
"3"
>
<td
colspan=
"3"
>
<a
href=
"{% url 'process_statement_create' pk=process.pk type=requirement.type %}"
>
add
</a>
<a
id=
"statement_add"
href=
"{% url 'process_statement_create' pk=process.pk type=requirement.type %}"
>
add
</a>
</td>
</td>
</tr>
</tr>
</tfoot>
</tfoot>
...
...
process/tests/common.py
View file @
ccc933a2
...
@@ -7,6 +7,86 @@ from backend.unittest import NamedObjects, PersonFixtureMixin
...
@@ -7,6 +7,86 @@ from backend.unittest import NamedObjects, PersonFixtureMixin
import
backend.models
as
bmodels
import
backend.models
as
bmodels
import
process.models
as
pmodels
import
process.models
as
pmodels
test_fingerprint1
=
"1793D6AB75663E6BF104953A634F4BD1E7AD5568"
test_fingerprint2
=
"66B4DFB68CB24EBBD8650BC4F4B4B0CC797EBFAB"
# Signed with key 1793D6AB75663E6BF104953A634F4BD1E7AD5568
test_fpr1_signed_invalid_text
=
"""
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
This is a test string
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBCAAGBQJXO5CSAAoJEAPWVoyDcnWpArgP/3EBdxc4gu5iQX7HQdmc93p8
4BSd/6evtqNtSJehQtZIRiJIqP3pcKDgnWQ+PqkEDkrMnlp7hQyLLXqENcwU54l1
Pj3OiS4O5EMkF4rvteIajX/GXO/qou7+zJYny/DBJUaDg9Dem7Zr8TzVoQsEMOcs
3VPdKQTZHOYcKvCoBMv34ZD9cKRsLACt7x+MTQIIZg62oaaCoHEraT6KSkkcn28P
IC5LTZaMRJm8di3zpxxHpM6RHhJpLEjmZNgRFaGPKam9ba7OeQy96tgTRYs4yKvx
gO2zcDLoXC2s/vhF7A0VTbg7GGfvFlQpRr6tempK39UbUaGGDlaPkyYeRdIXhxoP
yOUZS+ejGI2lxiECYWR5hVUO+Py+sHM2FWwphaRF226yPdq3bIIobQ22FgDaEiPw
bWrRVNG35TRJYSn4xb3XovIrcY8rmgOV5gSCpZh4Iy/92PuVg5gp1y2fFHp42PrC
OQqk1JXE1PHAX6ZqWQJW3MUcyBqKyEnz5Ylez7yyDqCWobey/s62dybYtdtQ/aZO
xBT0EeU3M5W1yBzEWVCLUUBIsmzFI+uUqZwO20XWmdMYFtWyvxmVQ9JCXo3ncWwf
a+KEa+sSqB8ZN0fIzGLL2uOOPdQGoVHxnObCJ5gBKjZ73JajY3cfLysY0UW45/eh
+5lxImpwauF6Tf+pMHKD
=86an
-----END PGP SIGNATURE-----
"""
# Signed with key 1793D6AB75663E6BF104953A634F4BD1E7AD5568
test_fpr1_signed_valid_text
=
"""
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I agree to uphold the Social Contract and the Debian Free Software Guidelines in my Debian work.
I have read the Debian Machine Usage Policy and I accept them.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBCAAGBQJXPCbAAAoJEAPWVoyDcnWpmtYQAJo8r4Ve1xSYKs2s9MwAZLiD
q5XWRo9SFmIOyu7jq4giTGA5GMOFiGOMDHMWSNDnraVfhAZ2CrtwvyvaHcsYMDLb
kumcBqE2wYJNVMlgDX7celUMeeSeIVXvk1ef3/m0R2L0b/f+p/6/4IzaR3ZVCbkv
JwqZ7XJLH0YKih50fpnKjYnKEzVNOKGXcwm9I7XXJkl9a8c9TkC7IXnbHyL2AuZX
/kvOv+Y0EWXLEBgQx2PbxxZoM31nFIIa+MNLdz8dEOgc7g1aR8CCT0XyGTViL8W5
rrZSGMxdTXLPf3v+GqfehCUMCvy6/R4oqny2ijYVlaPFrMhPlpa7ydtgstySxc8Z
bCNFbSQM1ZSZUhcyFLhq5SbXW3T74jUHF0ApeM6n92erb02HDmv1uqsNBnFJCqdt
Zhg0mm1YPlAEPx7RSCwt0Zyu0Cuj/wK1d6YakWkxZwj5wkRvejsuMjcjWA5q/84I
zGoXT7GlqGdrvczrecoE1nzvqF8m5QXxOthaSjPqEviEde4YhQWxJfItULsLzGEb
OD+WdwaUol7byxcxmUIy60lFYsl2ryTvvxaRX1eUZtBkeeyP70SNqIgm+pbz2yba
0YW/mUIu3a+Dct/X/b05acQNRFcEWu0YWF6neBxR3Xd4cX1TJ2+9ICxSe2B8auxr
lsFwsnOvPjKD0iEMVmGe
=zlA9
-----END PGP SIGNATURE-----
"""
# Signed with key 66B4DFB68CB24EBBD8650BC4F4B4B0CC797EBFAB
test_fpr2_signed_valid_text
=
"""
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I agree to uphold the Social Contract and the Debian Free Software Guidelines in my Debian work.
I have read the Debian Machine Usage Policy and I accept them.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBCAAGBQJXPCcaAAoJEB5qw/OH8O2sbD8QAMrbXQYAGA/8EmXkSMKcAisk
jSqxkBDbnNeXn+Vso5aT/aVY/n63v/uDh2YDlz9Q4rC1GWS23KaQAf35spkyLCua
NSw3gbRJWByTuPxp+E3M2+9N56ZJGFwHAeatxbZJUeP88Dtsp7F+he9FaT2BUFCb
zYV9IbR8g47B8BDSTxjURWg34gVxsghUnYW6kYT8ATI1xls5zweiOt1UCe7UKVqo
PFNgaEPjdsuqE8pYIcLNjwx/adXjbXVsu3U7aYXCfZNZfi9FocCBUL2w0Ry8RqQa
tw/Ag6nQY7e7T8eIu3n49qVV9QarfiqB4JoaH9KTDZn6BHM+IgIxYbZabMVq/+9H
O0yeJGt/Pj1SISchDcDzebsXZfLl4HYhtncKwjLVwlPcV6Iopmw7uXklzOgD1xim
eqj0s84751kt/68TU3Hps/7PzQfCOfs2GZ4XCUzRcnluKJROBWX+xg3z3zEa0Luy
7Kn2Pq+AYNc0T9r6Ii4ioxraq3o/4G8mNCo6HVEFAC6jEejxyBjN3xFb5hAAKzPM
qNOSwQp380PzgE1L8eYcvNaUPgPqRVdPJzLX04NRsAyFgxPkBCo5V3WRSQpbEozi
vEKSopp/HEL4wBq8JYlvA0DuHTB7+X91XI6LreJQAe+6Jo07iuqmeZd9/pl1Anch
1hXsFK826L36Be03CwGL
=io+s
-----END PGP SIGNATURE-----
"""
class
TestProcesses
(
NamedObjects
):
class
TestProcesses
(
NamedObjects
):
def
__init__
(
self
,
**
defaults
):
def
__init__
(
self
,
**
defaults
):
...
...
process/tests/test_process_req.py
0 → 100644
View file @
ccc933a2
# coding: utf8
from
__future__
import
print_function
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
from
django.utils.timezone
import
now
from
backend
import
const
from
backend
import
models
as
bmodels
from
backend.unittest
import
PersonFixtureMixin
,
ExpectedSets
,
TestSet
,
PageElements
import
process.models
as
pmodels
from
.common
import
ProcessFixtureMixin
,
get_all_process_types
,
test_fingerprint1
,
test_fpr1_signed_valid_text
class
TestProcessReq
(
ProcessFixtureMixin
,
TestCase
):
@
classmethod
def
__add_extra_tests__
(
cls
):
for
src
,
tgt
in
get_all_process_types
():
reqs
=
pmodels
.
Process
.
objects
.
compute_requirements
(
src
,
tgt
)
want_am
=
"am_ok"
in
reqs
visitors
=
[
None
,
"pending"
,
"dc"
,
"dc_ga"
,
"dm"
,
"dm_ga"
,
"dd_nu"
,
"dd_u"
,
"dd_e"
,
"dd_r"
,
"activeam"
,
"fd"
,
"dam"
,
"app"
]
if
want_am
:
visitors
.
append
(
"am"
)
for
type
in
reqs
:
for
visitor
in
visitors
:
if
want_am
:
cls
.
_add_method
(
cls
.
_test_perms
,
type
,
src
,
tgt
,
visitor
,
am
=
"dd_nu"
)
cls
.
_add_method
(
cls
.
_test_perms
,
type
,
src
,
tgt
,
visitor
,
am
=
"dd_u"
)
else
:
cls
.
_add_method
(
cls
.
_test_perms
,
type
,
src
,
tgt
,
visitor
)
@
classmethod
def
setUpClass
(
cls
):
super
(
TestProcessReq
,
cls
).
setUpClass
()
cls
.
page_elements
=
PageElements
()
cls
.
page_elements
.
add_id
(
"log_public"
)
cls
.
page_elements
.
add_id
(
"log_private"
)
cls
.
page_elements
.
add_id
(
"req_approve"
)
cls
.
page_elements
.
add_id
(
"req_unapprove"
)
cls
.
page_elements
.
add_id
(
"statement_add"
)
cls
.
page_elements
.
add_class
(
"statement_delete"
)
cls
.
page_elements_bytype
=
{}
for
req_type
in
(
"intent"
,
"sc_dmup"
,
"advocate"
,
"am_ok"
,
"keycheck"
):
cls
.
page_elements_bytype
[
req_type
]
=
cls
.
page_elements
.
clone
()
cls
.
page_elements_bytype
[
"am_ok"
].
add_id
(
"am_assign"
)
cls
.
page_elements_bytype
[
"am_ok"
].
add_id
(
"am_unassign"
)
def
assertPageElements
(
self
,
response
,
visit_perms
):
# Check page elements based on visit_perms
wanted
=
[]
if
"add_log"
in
visit_perms
:
wanted
+=
[
"log_public"
,
"log_private"
]
for
el
in
(
"req_approve"
,
"req_unapprove"
):
if
el
in
visit_perms
:
wanted
.
append
(
el
)
if
"edit_statements"
in
visit_perms
:
wanted
.
append
(
"statement_add"
)
wanted
.
append
(
"statement_delete"
)
self
.
assertContainsElements
(
response
,
self
.
page_elements
,
*
wanted
)
def
_test_perms
(
self
,
type
,
src
,
tgt
,
visitor
,
am
=
None
):
view
=
"process_req_"
+
type
self
.
persons
.
create
(
"app"
,
status
=
src
)
self
.
fingerprints
.
create
(
"app"
,
person
=
self
.
persons
.
app
,
fpr
=
test_fingerprint1
,
is_active
=
True
,
audit_skip
=
True
)
self
.
processes
.
create
(
"app"
,
person
=
self
.
persons
.
app
,
applying_for
=
tgt
,
fd_comment
=
"test"
)
if
am
is
not
None
:
self
.
persons
.
create
(
"am"
,
status
=
am
)
self
.
ams
.
create
(
"am"
,
person
=
self
.
persons
.
am
)
req
=
pmodels
.
Requirement
.
objects
.
get
(
process
=
self
.
processes
.
app
,
type
=
type
)
if
type
in
(
"intent"
,
"sc_dmup"
,
"advocate"
,
"am_ok"
):
pmodels
.
Statement
.
objects
.
create
(
requirement
=
req
,
fpr
=
self
.
fingerprints
.
app
,
statement
=
test_fpr1_signed_valid_text
,
uploaded_by
=
self
.
persons
.
app
,
uploaded_time
=
now
())
client
=
self
.
make_test_client
(
visitor
)
response
=
client
.
get
(
reverse
(
view
,
args
=
[
self
.
processes
.
app
.
pk
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
visit_perms
=
req
.
permissions_of
(
self
.
persons
[
visitor
])
self
.
assertPageElements
(
response
,
visit_perms
)
# Assign am and repeat visit
if
am
:
pmodels
.
AMAssignment
.
objects
.
create
(
process
=
self
.
processes
.
app
,
am
=
self
.
ams
.
am
,
assigned_by
=
self
.
persons
[
"fd"
],
assigned_time
=
now
())
response
=
client
.
get
(
reverse
(
view
,
args
=
[
self
.
processes
.
app
.
pk
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
visit_perms
=
req
.
permissions_of
(
self
.
persons
[
visitor
])
self
.
assertPageElements
(
response
,
visit_perms
)
process/urls.py
View file @
ccc933a2
...
@@ -16,13 +16,13 @@ urlpatterns = [
...
@@ -16,13 +16,13 @@ urlpatterns = [
url
(
r
'^(?P<pk>\d+)/advocate$'
,
views
.
ReqAdvocate
.
as_view
(),
name
=
"process_req_advocate"
),
url
(
r
'^(?P<pk>\d+)/advocate$'
,
views
.
ReqAdvocate
.
as_view
(),
name
=
"process_req_advocate"
),
url
(
r
'^(?P<pk>\d+)/am_ok$'
,
views
.
ReqAM
.
as_view
(),
name
=
"process_req_am_ok"
),
url
(
r
'^(?P<pk>\d+)/am_ok$'
,
views
.
ReqAM
.
as_view
(),
name
=
"process_req_am_ok"
),
url
(
r
'^(?P<pk>\d+)/keycheck$'
,
views
.
ReqKeycheck
.
as_view
(),
name
=
"process_req_keycheck"
),
url
(
r
'^(?P<pk>\d+)/keycheck$'
,
views
.
ReqKeycheck
.
as_view
(),
name
=
"process_req_keycheck"
),
url
(
r
'^(?P<pk>\d+)/assign_am$'
,
views
.
AssignAM
.
as_view
(),
name
=
"process_assign_am"
),
url
(
r
'^(?P<pk>\d+)/assign_am$'
,
views
.
AssignAM
.
as_view
(),
name
=
"process_assign_am"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/unassign_am$'
,
views
.
UnassignAM
.
as_view
(),
name
=
"process_unassign_am"
),
url
(
r
'^(?P<pk>\d+)/unassign_am$'
,
views
.
UnassignAM
.
as_view
(),
name
=
"process_unassign_am"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/(?P<type>[^/]+)/statement/create$'
,
views
.
StatementCreate
.
as_view
(),
name
=
"process_statement_create"
),
url
(
r
'^(?P<pk>\d+)/(?P<type>[^/]+)/statement/create$'
,
views
.
StatementCreate
.
as_view
(),
name
=
"process_statement_create"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/(?P<type>[^/]+)/statement/(?P<st>\d+)/delete$'
,
views
.
StatementDelete
.
as_view
(),
name
=
"process_statement_delete"
),
url
(
r
'^(?P<pk>\d+)/(?P<type>[^/]+)/statement/(?P<st>\d+)/delete$'
,
views
.
StatementDelete
.
as_view
(),
name
=
"process_statement_delete"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/(?P<type>[^/]+)/statement/(?P<st>\d+)/raw$'
,
views
.
StatementRaw
.
as_view
(),
name
=
"process_statement_raw"
),
url
(
r
'^(?P<pk>\d+)/(?P<type>[^/]+)/statement/(?P<st>\d+)/raw$'
,
views
.
StatementRaw
.
as_view
(),
name
=
"process_statement_raw"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/add_log$'
,
views
.
AddProcessLog
.
as_view
(),
name
=
"process_add_log"
),
url
(
r
'^(?P<pk>\d+)/add_log$'
,
views
.
AddProcessLog
.
as_view
(),
name
=
"process_add_log"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/(?P<type>[^/]+)/add_log$'
,
views
.
AddProcessLog
.
as_view
(),
name
=
"process_add_requirement_log"
),
url
(
r
'^(?P<pk>\d+)/(?P<type>[^/]+)/add_log$'
,
views
.
AddProcessLog
.
as_view
(),
name
=
"process_add_requirement_log"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/mailbox/download$'
,
views
.
MailArchive
.
as_view
(),
name
=
"process_mailbox_download"
),
url
(
r
'^(?P<pk>\d+)/mailbox/download$'
,
views
.
MailArchive
.
as_view
(),
name
=
"process_mailbox_download"
),
# TODO: test
url
(
r
'^(?P<pk>\d+)/mailbox$'
,
views
.
DisplayMailArchive
.
as_view
(),
name
=
"process_mailbox_show"
),
url
(
r
'^(?P<pk>\d+)/mailbox$'
,
views
.
DisplayMailArchive
.
as_view
(),
name
=
"process_mailbox_show"
),
# TODO: test
]
]
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment