Format all the things (#991)

* Format Javascript and CSS files with `prettier`: `prettier --write 'CTFd/themes/**/*'`
* Format Python with `black`: `black CTFd` & `black tests`
* Travis now uses xenial instead of trusty.
This commit is contained in:
Kevin Chung
2019-05-11 21:09:37 -04:00
committed by GitHub
parent 3d23ece370
commit 6833378c36
201 changed files with 9561 additions and 9107 deletions

View File

@@ -2,12 +2,14 @@
# -*- coding: utf-8 -*-
from CTFd.models import Notifications
from tests.helpers import (create_ctfd,
destroy_ctfd,
register_user,
login_as_user,
gen_challenge,
gen_notification)
from tests.helpers import (
create_ctfd,
destroy_ctfd,
register_user,
login_as_user,
gen_challenge,
gen_notification,
)
def test_api_notifications_get():
@@ -18,20 +20,20 @@ def test_api_notifications_get():
with login_as_user(app) as client:
# test_api_notifications_get
"""Can the users get /api/v1/notifications"""
r = client.get('/api/v1/notifications', json="")
r = client.get("/api/v1/notifications", json="")
assert r.status_code == 200
assert len(r.get_json()['data']) == 1
assert len(r.get_json()["data"]) == 1
# test_api_get_notification_detail
r = client.get('/api/v1/notifications/1', json="")
r = client.get("/api/v1/notifications/1", json="")
assert r.status_code == 200
resp = r.get_json()
assert resp['data']['title'] == 'title'
assert resp['data']['content'] == 'content'
assert resp["data"]["title"] == "title"
assert resp["data"]["content"] == "content"
# test_api_notifications_post_non_admin
"""Can the users post /api/v1/notifications if not admin"""
r = client.post('/api/v1/notifications', json="")
r = client.post("/api/v1/notifications", json="")
assert r.status_code == 403
destroy_ctfd(app)
@@ -42,9 +44,9 @@ def test_api_notifications_post_admin():
with app.app_context():
gen_challenge(app.db)
with login_as_user(app, name="admin") as client:
r = client.post('/api/v1/notifications', json={
"title": "title",
"content": "content"})
r = client.post(
"/api/v1/notifications", json={"title": "title", "content": "content"}
)
assert r.status_code == 200
destroy_ctfd(app)
@@ -57,9 +59,9 @@ def test_api_delete_notifications_by_admin():
gen_notification(app.db)
assert Notifications.query.count() == 1
with login_as_user(app, name="admin") as client:
r = client.delete('/api/v1/notifications/1', json="")
r = client.delete("/api/v1/notifications/1", json="")
assert r.status_code == 200
assert r.get_json()['success'] is True
assert r.get_json()["success"] is True
assert Notifications.query.count() == 0
destroy_ctfd(app)
@@ -73,7 +75,7 @@ def test_api_delete_notifications_by_user():
gen_notification(app.db)
assert Notifications.query.count() == 1
with login_as_user(app) as client:
r = client.delete('/api/v1/notifications/1', json="")
r = client.delete("/api/v1/notifications/1", json="")
assert r.status_code == 403
assert Notifications.query.count() == 1
destroy_ctfd(app)