This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/tests/test_render_2_0.py

62 lines
1.6 KiB
Python
Raw Normal View History

import pytest
2022-03-15 10:17:05 +00:00
from flask.testing import FlaskClient
from flask_wtf.csrf import generate_csrf
2022-03-15 10:17:05 +00:00
2022-03-17 10:50:57 +00:00
from ereuse_devicehub.client import UserClient, UserClientFlask
2022-03-15 10:17:05 +00:00
from ereuse_devicehub.devicehub import Devicehub
from tests import conftest
2022-03-15 10:17:05 +00:00
@pytest.mark.mvp
2022-03-15 10:17:05 +00:00
# @pytest.mark.usefixtures()
@pytest.mark.usefixtures(conftest.app_context.__name__)
2022-03-15 10:17:05 +00:00
def test_login(user: UserClient, app: Devicehub):
"""Checks a simple login"""
client = FlaskClient(app, use_cookies=True)
2022-03-15 10:17:05 +00:00
body, status, headers = client.get('/login/')
body = next(body).decode("utf-8")
assert status == '200 OK'
assert "Login to Your Account" in body
data = {
'email': user.email,
'password': 'foo',
'remember': False,
'csrf_token': generate_csrf(),
}
body, status, headers = client.post('/login/', data=data, follow_redirects=True)
2022-03-15 10:17:05 +00:00
body = next(body).decode("utf-8")
assert status == '200 OK'
assert "Login to Your Account" not in body
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
2022-03-17 10:50:57 +00:00
def test_inventory(user3: UserClientFlask):
body, status = user3.get('/inventory/device/')
assert status == '200 OK'
assert "Unassgined" in body
@pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__)
def test_add_lot(user3: UserClientFlask):
body, status = user3.get('/inventory/lot/add/')
assert status == '200 OK'
assert "Add a new lot" in body
data = {
2022-03-17 10:50:57 +00:00
'name': 'lot1',
'csrf_token': generate_csrf(),
}
2022-03-17 10:50:57 +00:00
# import pdb; pdb.set_trace()
body, status = user3.post('/inventory/lot/add/', data=data)
assert status == '200 OK'
2022-03-17 10:50:57 +00:00
assert "lot1" in body