Add tests update invalid milestone in bulk
parent
ad757f233b
commit
305b8f048f
|
@ -265,7 +265,7 @@ class IssueViewSet(AssignedToSignalMixin, OCCResourceMixin, VotedResourceMixin,
|
||||||
|
|
||||||
self.check_permissions(request, "bulk_update_milestone", project)
|
self.check_permissions(request, "bulk_update_milestone", project)
|
||||||
|
|
||||||
ret = services.update_tasks_milestone_in_bulk(data["bulk_issues"], milestone)
|
ret = services.update_issues_milestone_in_bulk(data["bulk_issues"], milestone)
|
||||||
|
|
||||||
return response.Ok(ret)
|
return response.Ok(ret)
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ def snapshot_issues_in_bulk(bulk_data, user):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def update_tasks_milestone_in_bulk(bulk_data: list, milestone: object):
|
def update_issues_milestone_in_bulk(bulk_data: list, milestone: object):
|
||||||
"""
|
"""
|
||||||
Update the milestone some issues adding
|
Update the milestone some issues adding
|
||||||
`bulk_data` should be a list of dicts with the following format:
|
`bulk_data` should be a list of dicts with the following format:
|
||||||
|
@ -106,6 +106,7 @@ def update_tasks_milestone_in_bulk(bulk_data: list, milestone: object):
|
||||||
# CSV
|
# CSV
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
|
|
||||||
def issues_to_csv(project, queryset):
|
def issues_to_csv(project, queryset):
|
||||||
csv_data = io.StringIO()
|
csv_data = io.StringIO()
|
||||||
fieldnames = ["id", "ref", "subject", "description", "sprint_id", "sprint",
|
fieldnames = ["id", "ref", "subject", "description", "sprint_id", "sprint",
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from taiga.base.api import serializers
|
from taiga.base.api import serializers
|
||||||
from taiga.base.api import validators
|
from taiga.base.api import validators
|
||||||
|
|
|
@ -144,6 +144,7 @@ def update_tasks_milestone_in_bulk(bulk_data: list, milestone: object):
|
||||||
|
|
||||||
return task_milestones
|
return task_milestones
|
||||||
|
|
||||||
|
|
||||||
#####################################################
|
#####################################################
|
||||||
# CSV
|
# CSV
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
|
@ -792,6 +792,35 @@ def test_api_update_milestone_in_bulk(client):
|
||||||
assert response.data[i3.id] == milestone2.id
|
assert response.data[i3.id] == milestone2.id
|
||||||
|
|
||||||
|
|
||||||
|
def test_api_update_milestone_in_bulk_invalid_milestone(client):
|
||||||
|
project = f.create_project()
|
||||||
|
f.MembershipFactory.create(project=project, user=project.owner, is_admin=True)
|
||||||
|
|
||||||
|
milestone1 = f.MilestoneFactory(project=project)
|
||||||
|
milestone2 = f.MilestoneFactory()
|
||||||
|
|
||||||
|
i1 = f.create_issue(project=project, milestone=milestone1)
|
||||||
|
i2 = f.create_issue(project=project, milestone=milestone1)
|
||||||
|
i3 = f.create_issue(project=project, milestone=milestone1)
|
||||||
|
|
||||||
|
url = reverse("issues-bulk-update-milestone")
|
||||||
|
data = {
|
||||||
|
"project_id": project.id,
|
||||||
|
"milestone_id": milestone2.id,
|
||||||
|
"bulk_issues": [
|
||||||
|
{"issue_id": i1.id},
|
||||||
|
{"issue_id": i2.id},
|
||||||
|
{"issue_id": i3.id}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
client.login(project.owner)
|
||||||
|
response = client.json.post(url, json.dumps(data))
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
assert "milestone_id" in response.data
|
||||||
|
|
||||||
|
|
||||||
def test_get_issues(client):
|
def test_get_issues(client):
|
||||||
user = f.UserFactory.create()
|
user = f.UserFactory.create()
|
||||||
project = f.ProjectFactory.create(owner=user)
|
project = f.ProjectFactory.create(owner=user)
|
||||||
|
|
|
@ -575,6 +575,35 @@ def test_api_update_milestone_in_bulk(client):
|
||||||
assert response.data[task3.id] == milestone2.id
|
assert response.data[task3.id] == milestone2.id
|
||||||
|
|
||||||
|
|
||||||
|
def test_api_update_milestone_in_bulk_invalid_milestone(client):
|
||||||
|
user = f.UserFactory.create()
|
||||||
|
project = f.ProjectFactory.create(owner=user, default_task_status=None)
|
||||||
|
f.MembershipFactory.create(project=project, user=user, is_admin=True)
|
||||||
|
|
||||||
|
milestone1 = f.MilestoneFactory(project=project)
|
||||||
|
milestone2 = f.MilestoneFactory()
|
||||||
|
task1 = f.create_task(project=project, milestone=milestone1)
|
||||||
|
task2 = f.create_task(project=project, milestone=milestone1)
|
||||||
|
task3 = f.create_task(project=project, milestone=milestone1)
|
||||||
|
|
||||||
|
url = reverse("tasks-bulk-update-milestone")
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"project_id": project.id,
|
||||||
|
"milestone_id": milestone2.id,
|
||||||
|
"bulk_tasks": [{"task_id": task1.id, "order": 1},
|
||||||
|
{"task_id": task2.id, "order": 2},
|
||||||
|
{"task_id": task3.id, "order": 3}]
|
||||||
|
}
|
||||||
|
|
||||||
|
client.login(project.owner)
|
||||||
|
|
||||||
|
response = client.json.post(url, json.dumps(data))
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
assert "milestone_id" in response.data
|
||||||
|
|
||||||
|
|
||||||
def test_get_invalid_csv(client):
|
def test_get_invalid_csv(client):
|
||||||
url = reverse("tasks-csv")
|
url = reverse("tasks-csv")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue