Beispiel #1
0
def test_dao_fetch_service_creator(notify_db_session):
    active_user_1 = create_user(email="*****@*****.**", state="active")
    active_user_2 = create_user(email="*****@*****.**", state="active")
    service = Service(
        name="service_name",
        email_from="email_from",
        message_limit=1000,
        restricted=False,
        created_by=active_user_1,
    )
    dao_create_service(
        service,
        active_user_1,
        service_permissions=[
            SMS_TYPE,
            EMAIL_TYPE,
            INTERNATIONAL_SMS_TYPE,
        ],
    )

    service.created_by_id = active_user_2.id
    service.name = "New Name"
    dao_update_service(service)

    assert Service.query.count() == 1

    history_model = Service.get_history_model()
    entries = history_model.query.all()
    assert len(entries) == 2
    assert entries[1].created_by_id == active_user_2.id
    assert active_user_1 == dao_fetch_service_creator(service.id)