Black formatting
This commit is contained in:
parent
f526ed5166
commit
21ec87cee4
10 changed files with 276 additions and 227 deletions
|
@ -16,19 +16,20 @@ After that, view contents and behaviors.
|
|||
|
||||
# ### SMOKETESTS ###
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_todo_setup(todo_setup):
|
||||
assert Task.objects.all().count() == 6
|
||||
|
||||
|
||||
def test_view_list_lists(todo_setup, admin_client):
|
||||
url = reverse('todo:lists')
|
||||
url = reverse("todo:lists")
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_view_reorder(todo_setup, admin_client):
|
||||
url = reverse('todo:reorder_tasks')
|
||||
url = reverse("todo:reorder_tasks")
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 201 # Special case return value expected
|
||||
|
||||
|
@ -37,53 +38,55 @@ def test_view_external_add(todo_setup, admin_client, settings):
|
|||
default_list = TaskList.objects.first()
|
||||
settings.TODO_DEFAULT_LIST_SLUG = default_list.slug
|
||||
assert settings.TODO_DEFAULT_LIST_SLUG == default_list.slug
|
||||
url = reverse('todo:external_add')
|
||||
url = reverse("todo:external_add")
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_view_mine(todo_setup, admin_client):
|
||||
url = reverse('todo:mine')
|
||||
url = reverse("todo:mine")
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_view_list_completed(todo_setup, admin_client):
|
||||
tlist = TaskList.objects.get(slug="zip")
|
||||
url = reverse('todo:list_detail_completed', kwargs={'list_id': tlist.id, 'list_slug': tlist.slug})
|
||||
url = reverse(
|
||||
"todo:list_detail_completed", kwargs={"list_id": tlist.id, "list_slug": tlist.slug}
|
||||
)
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_view_list(todo_setup, admin_client):
|
||||
tlist = TaskList.objects.get(slug="zip")
|
||||
url = reverse('todo:list_detail', kwargs={'list_id': tlist.id, 'list_slug': tlist.slug})
|
||||
url = reverse("todo:list_detail", kwargs={"list_id": tlist.id, "list_slug": tlist.slug})
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_del_list(todo_setup, admin_client):
|
||||
tlist = TaskList.objects.get(slug="zip")
|
||||
url = reverse('todo:del_list', kwargs={'list_id': tlist.id, 'list_slug': tlist.slug})
|
||||
url = reverse("todo:del_list", kwargs={"list_id": tlist.id, "list_slug": tlist.slug})
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_view_add_list(todo_setup, admin_client):
|
||||
url = reverse('todo:add_list')
|
||||
url = reverse("todo:add_list")
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_view_task_detail(todo_setup, admin_client):
|
||||
task = Task.objects.first()
|
||||
url = reverse('todo:task_detail', kwargs={'task_id': task.id})
|
||||
url = reverse("todo:task_detail", kwargs={"task_id": task.id})
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_view_search(todo_setup, admin_client):
|
||||
url = reverse('todo:search')
|
||||
url = reverse("todo:search")
|
||||
response = admin_client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
@ -100,11 +103,11 @@ def test_no_javascript_in_task_note(todo_setup, client):
|
|||
"priority": 10,
|
||||
"title": title,
|
||||
"note": note,
|
||||
'add_edit_task': 'Submit'
|
||||
"add_edit_task": "Submit",
|
||||
}
|
||||
|
||||
client.login(username='u2', password="password")
|
||||
url = reverse('todo:list_detail', kwargs={"list_id": task_list.id, "list_slug": task_list.slug})
|
||||
client.login(username="u2", password="password")
|
||||
url = reverse("todo:list_detail", kwargs={"list_id": task_list.id, "list_slug": task_list.slug})
|
||||
|
||||
response = client.post(url, data)
|
||||
assert response.status_code == 302
|
||||
|
@ -118,7 +121,7 @@ def test_no_javascript_in_task_note(todo_setup, client):
|
|||
@pytest.mark.django_db
|
||||
def test_no_javascript_in_comments(todo_setup, client):
|
||||
user = get_user_model().objects.get(username="u2")
|
||||
client.login(username='u2', password="password")
|
||||
client.login(username="u2", password="password")
|
||||
|
||||
task = Task.objects.first()
|
||||
task.created_by = user
|
||||
|
@ -127,11 +130,8 @@ def test_no_javascript_in_comments(todo_setup, client):
|
|||
user.groups.add(task.task_list.group)
|
||||
|
||||
comment = "foo <script>alert('oh noez');</script> bar"
|
||||
data = {
|
||||
"comment-body": comment,
|
||||
"add_comment": 'Submit'
|
||||
}
|
||||
url = reverse('todo:task_detail', kwargs={"task_id": task.id})
|
||||
data = {"comment-body": comment, "add_comment": "Submit"}
|
||||
url = reverse("todo:task_detail", kwargs={"task_id": task.id})
|
||||
|
||||
response = client.post(url, data)
|
||||
assert response.status_code == 200
|
||||
|
@ -152,7 +152,7 @@ These exercise our custom @staff_only decorator without calling that function ex
|
|||
|
||||
|
||||
def test_view_add_list_nonadmin(todo_setup, client):
|
||||
url = reverse('todo:add_list')
|
||||
url = reverse("todo:add_list")
|
||||
client.login(username="you", password="password")
|
||||
response = client.get(url)
|
||||
assert response.status_code == 403
|
||||
|
@ -160,7 +160,7 @@ def test_view_add_list_nonadmin(todo_setup, client):
|
|||
|
||||
def test_view_del_list_nonadmin(todo_setup, client):
|
||||
tlist = TaskList.objects.get(slug="zip")
|
||||
url = reverse('todo:del_list', kwargs={'list_id': tlist.id, 'list_slug': tlist.slug})
|
||||
url = reverse("todo:del_list", kwargs={"list_id": tlist.id, "list_slug": tlist.slug})
|
||||
client.login(username="you", password="password")
|
||||
response = client.get(url)
|
||||
assert response.status_code == 403
|
||||
|
@ -170,7 +170,7 @@ def test_view_list_mine(todo_setup, client):
|
|||
"""View a list in a group I belong to.
|
||||
"""
|
||||
tlist = TaskList.objects.get(slug="zip") # User u1 is in this group's list
|
||||
url = reverse('todo:list_detail', kwargs={'list_id': tlist.id, 'list_slug': tlist.slug})
|
||||
url = reverse("todo:list_detail", kwargs={"list_id": tlist.id, "list_slug": tlist.slug})
|
||||
client.login(username="u1", password="password")
|
||||
response = client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
@ -180,7 +180,7 @@ def test_view_list_not_mine(todo_setup, client):
|
|||
"""View a list in a group I don't belong to.
|
||||
"""
|
||||
tlist = TaskList.objects.get(slug="zip") # User u1 is in this group, user u2 is not.
|
||||
url = reverse('todo:list_detail', kwargs={'list_id': tlist.id, 'list_slug': tlist.slug})
|
||||
url = reverse("todo:list_detail", kwargs={"list_id": tlist.id, "list_slug": tlist.slug})
|
||||
client.login(username="u2", password="password")
|
||||
response = client.get(url)
|
||||
assert response.status_code == 403
|
||||
|
@ -190,7 +190,7 @@ def test_view_task_mine(todo_setup, client):
|
|||
# Users can always view their own tasks
|
||||
task = Task.objects.filter(created_by__username="u1").first()
|
||||
client.login(username="u1", password="password")
|
||||
url = reverse('todo:task_detail', kwargs={'task_id': task.id})
|
||||
url = reverse("todo:task_detail", kwargs={"task_id": task.id})
|
||||
response = client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
@ -205,7 +205,7 @@ def test_view_task_my_group(todo_setup, client, django_user_model):
|
|||
|
||||
# Now u2 should be able to view one of u1's tasks.
|
||||
task = Task.objects.filter(created_by__username="u1").first()
|
||||
url = reverse('todo:task_detail', kwargs={'task_id': task.id})
|
||||
url = reverse("todo:task_detail", kwargs={"task_id": task.id})
|
||||
client.login(username="u2", password="password")
|
||||
response = client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
@ -215,7 +215,8 @@ def test_view_task_not_in_my_group(todo_setup, client):
|
|||
# User canNOT view a task that isn't theirs if the two users are not in a shared group.
|
||||
# For this we can use the fixture data as-is.
|
||||
task = Task.objects.filter(created_by__username="u1").first()
|
||||
url = reverse('todo:task_detail', kwargs={'task_id': task.id})
|
||||
url = reverse("todo:task_detail", kwargs={"task_id": task.id})
|
||||
client.login(username="u2", password="password")
|
||||
response = client.get(url)
|
||||
assert response.status_code == 403
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue