Skip to content

Commit

Permalink
test: patch db session
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidalgarcia committed Apr 27, 2020
1 parent b013929 commit 5caeb4f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/conftest.py
Expand Up @@ -12,6 +12,7 @@
from uuid import uuid4

import pytest
from mock import patch
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy_utils import create_database, database_exists, drop_database
Expand Down Expand Up @@ -61,7 +62,9 @@ def test_create_workflow(session):
@pytest.fixture
def new_user(session):
"""Create new user."""
user = User(email=f'{uuid4()}@reana.io', access_token='secretkey')
with patch('reana_db.database.Session', return_value=session):
user = User(email=f'{uuid4()}@reana.io',
access_token=f'secretkey-{uuid4()}')
session.add(user)
session.commit()
return user

0 comments on commit 5caeb4f

Please sign in to comment.