86 lines
2.5 KiB
Python
86 lines
2.5 KiB
Python
from django.core.urlresolvers import reverse
|
|
from taiga.base.utils import json
|
|
|
|
from .. import factories as f
|
|
|
|
import pytest
|
|
pytestmark = pytest.mark.django_db
|
|
|
|
|
|
def test_create_project(client):
|
|
user = f.create_user()
|
|
url = reverse("projects-list")
|
|
data = {"name": "project name", "description": "project description"}
|
|
|
|
client.login(user)
|
|
response = client.json.post(url, json.dumps(data))
|
|
|
|
assert response.status_code == 201
|
|
|
|
|
|
def test_partially_update_project(client):
|
|
project = f.create_project()
|
|
url = reverse("projects-detail", kwargs={"pk": project.pk})
|
|
data = {"name": ""}
|
|
|
|
client.login(project.owner)
|
|
response = client.json.patch(url, json.dumps(data))
|
|
assert response.status_code == 400
|
|
|
|
|
|
def test_us_status_slug_generation(client):
|
|
us_status = f.UserStoryStatusFactory(name="NEW")
|
|
assert us_status.slug == "new"
|
|
|
|
client.login(us_status.project.owner)
|
|
|
|
url = reverse("userstory-statuses-detail", kwargs={"pk": us_status.pk})
|
|
|
|
data = {"name": "new"}
|
|
response = client.json.patch(url, json.dumps(data))
|
|
assert response.status_code == 200
|
|
assert response.data["slug"] == "new"
|
|
|
|
data = {"name": "new status"}
|
|
response = client.json.patch(url, json.dumps(data))
|
|
assert response.status_code == 200
|
|
assert response.data["slug"] == "new-status"
|
|
|
|
|
|
def test_task_status_slug_generation(client):
|
|
task_status = f.TaskStatusFactory(name="NEW")
|
|
assert task_status.slug == "new"
|
|
|
|
client.login(task_status.project.owner)
|
|
|
|
url = reverse("task-statuses-detail", kwargs={"pk": task_status.pk})
|
|
|
|
data = {"name": "new"}
|
|
response = client.json.patch(url, json.dumps(data))
|
|
assert response.status_code == 200
|
|
assert response.data["slug"] == "new"
|
|
|
|
data = {"name": "new status"}
|
|
response = client.json.patch(url, json.dumps(data))
|
|
assert response.status_code == 200
|
|
assert response.data["slug"] == "new-status"
|
|
|
|
|
|
def test_issue_status_slug_generation(client):
|
|
issue_status = f.IssueStatusFactory(name="NEW")
|
|
assert issue_status.slug == "new"
|
|
|
|
client.login(issue_status.project.owner)
|
|
|
|
url = reverse("issue-statuses-detail", kwargs={"pk": issue_status.pk})
|
|
|
|
data = {"name": "new"}
|
|
response = client.json.patch(url, json.dumps(data))
|
|
assert response.status_code == 200
|
|
assert response.data["slug"] == "new"
|
|
|
|
data = {"name": "new status"}
|
|
response = client.json.patch(url, json.dumps(data))
|
|
assert response.status_code == 200
|
|
assert response.data["slug"] == "new-status"
|