Add tests for the edit_question view
This commit is contained in:
parent
a69c85c588
commit
b032e793de
@ -35,8 +35,8 @@
|
||||
<span class="">Created By ItIsGood.com</span>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
@ -20,8 +20,8 @@
|
||||
<span class="">Created By ItIsGood.com</span>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
@ -19,7 +19,7 @@ def session():
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def init_database(client, session):
|
||||
def init_database(session):
|
||||
init_db()
|
||||
|
||||
user_datastore = SQLAlchemySessionUserDatastore(session, User, Role)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import json
|
||||
from html5validate import validate
|
||||
from flask.testing import FlaskClient
|
||||
|
||||
|
||||
@ -9,3 +11,29 @@ def test_admin_home_with_basic_user(client: FlaskClient, login_basic_user):
|
||||
def test_admin_home_with_admin_user(client: FlaskClient, login_admin_user):
|
||||
response = client.get("/admin/")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_edit_question_view_gives_json(client: FlaskClient, login_admin_user):
|
||||
response = client.get("/admin/questions/edit/0", headers={"Accept": "application/json"})
|
||||
assert response.headers.get("Content-Type") == "application/json"
|
||||
data = json.loads(response.data)
|
||||
assert "question_id" in data.keys()
|
||||
assert type(data["question_id"]) is int
|
||||
assert "question" in data.keys()
|
||||
assert type(data["question"]) is str
|
||||
assert "answer" in data.keys()
|
||||
assert type(data["answer"]) is str
|
||||
assert "addresses" in data.keys()
|
||||
assert type(data["addresses"]) is str
|
||||
|
||||
|
||||
def test_edit_question_view_gives_html(client: FlaskClient, login_admin_user):
|
||||
response = client.get("/admin/questions/edit/0", headers={"Accept": "text/html"})
|
||||
assert "text/html" in response.headers.get("Content-Type")
|
||||
assert validate(response.data) is None
|
||||
|
||||
|
||||
def test_edit_question_view(client: FlaskClient, login_admin_user):
|
||||
response = client.get("/admin/questions/edit/0")
|
||||
assert "text/html" in response.headers.get("Content-Type")
|
||||
assert validate(response.data) is None
|
||||
|
Loading…
Reference in New Issue
Block a user