import pytest from flask import g from ereuse_devicehub.db import db from ereuse_devicehub.resources.device.models import Device from ereuse_devicehub.resources.event.models import EventWithOneDevice from tests.conftest import create_user @pytest.mark.usefixtures('app_context') def test_author(): """ Checks the default created author. Note that the author can be accessed after inserting the row. """ user = create_user() g.user = user e = EventWithOneDevice(device=Device()) db.session.add(e) assert e.author is None assert e.author_id is None db.session.commit() assert e.author == user