1
0
forked from ScoDoc/ScoDoc
ScoDoc/tests/api/test_api_logos.py

74 lines
2.0 KiB
Python
Raw Normal View History

2021-12-24 06:08:35 +01:00
#!/usr/bin/env python3
# -*- mode: python -*-
# -*- coding: utf-8 -*-
"""Exemple utilisation API ScoDoc 9 avec jeton obtenu par basic authentication
utilisation:
à faire fonctionner en environnment de test (FLASK_ENV=test_api dans le fichier .env)
2021-12-24 06:08:35 +01:00
pytest tests/api/test_api_logos.py
"""
# XXX TODO
# Ce test a une logique très différente des autres : A UNIFIER
from tests.api.setup_test_api import API_URL
2021-12-24 06:08:35 +01:00
from scodoc import app
from tests.unit.config_test_logos import (
create_super_token,
create_admin_token,
create_lambda_token,
create_logos,
create_dept,
)
def test_super_access(create_super_token):
"""
Route: /logos
"""
2021-12-24 06:08:35 +01:00
dept1, dept2, dept3, token = create_super_token
headers = {"Authorization": f"Bearer {token}"}
2021-12-24 06:08:35 +01:00
with app.test_client() as client:
response = client.get(API_URL + "/logos", headers=headers)
2021-12-24 06:08:35 +01:00
assert response.status_code == 200
assert response.json is not None
def test_admin_access(create_admin_token):
"""
Route:
"""
2021-12-24 06:08:35 +01:00
dept1, dept2, dept3, token = create_admin_token
headers = {"Authorization": f"Bearer {token}"}
with app.test_client() as client:
response = client.get(API_URL + "/logos", headers=headers)
2021-12-24 06:08:35 +01:00
assert response.status_code == 401
def test_lambda_access(create_lambda_token):
"""
Route:
"""
2021-12-24 06:08:35 +01:00
dept1, dept2, dept3, token = create_lambda_token
headers = {"Authorization": f"Bearer {token}"}
with app.test_client() as client:
response = client.get(API_URL + "/logos", headers=headers)
2021-12-24 06:08:35 +01:00
assert response.status_code == 401
def test_initial_with_header_and_footer(create_super_token):
"""
Route:
"""
2021-12-24 06:08:35 +01:00
dept1, dept2, dept3, token = create_super_token
headers = {"Authorization": f"Bearer {token}"}
with app.test_client() as client:
response = client.get(API_URL + "/logos", headers=headers)
2021-12-24 06:08:35 +01:00
assert response.status_code == 200
assert response.json is not None
assert len(response.json) == 7