mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 07:26:18 -05:00
Testing optional_session.
This commit is contained in:
parent
30affa20cd
commit
0bedec533e
1 changed files with 19 additions and 0 deletions
19
wrolpi/test/test_db.py
Normal file
19
wrolpi/test/test_db.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import pytest
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from wrolpi.db import optional_session
|
||||
|
||||
|
||||
def test_optional_session(test_session):
|
||||
url = test_session.get_bind().url
|
||||
|
||||
@optional_session()
|
||||
def func(session: Session):
|
||||
assert session.get_bind().url == url
|
||||
|
||||
func()
|
||||
func(session=test_session)
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
# keyword must be used.
|
||||
func(test_session)
|
||||
Loading…
Add table
Add a link
Reference in a new issue