2016-01-08 12:18:12 +00:00
|
|
|
import pytest
|
2016-01-11 15:07:13 +00:00
|
|
|
from app.models import (User, Service)
|
2016-01-11 17:19:06 +00:00
|
|
|
from app.dao.users_dao import (save_model_user, get_model_users)
|
|
|
|
|
from app.dao.services_dao import save_model_service
|
2016-01-08 12:18:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
|
|
|
def sample_user(notify_db,
|
|
|
|
|
notify_db_session,
|
|
|
|
|
email="notify@digital.cabinet-office.gov.uk"):
|
2016-01-11 15:07:13 +00:00
|
|
|
user = User(**{'email_address': email})
|
2016-01-11 17:19:06 +00:00
|
|
|
save_model_user(user)
|
2016-01-11 15:07:13 +00:00
|
|
|
return user
|
2016-01-08 12:18:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
|
|
|
def sample_service(notify_db,
|
|
|
|
|
notify_db_session,
|
|
|
|
|
service_name="Sample service",
|
|
|
|
|
user=None):
|
|
|
|
|
if user is None:
|
|
|
|
|
user = sample_user(notify_db, notify_db_session)
|
2016-01-11 15:07:13 +00:00
|
|
|
data = {
|
|
|
|
|
'name': service_name,
|
|
|
|
|
'users': [user],
|
|
|
|
|
'limit': 1000,
|
|
|
|
|
'active': False,
|
|
|
|
|
'restricted': False}
|
|
|
|
|
service = Service(**data)
|
2016-01-11 17:19:06 +00:00
|
|
|
save_model_service(service)
|
2016-01-11 15:07:13 +00:00
|
|
|
return service
|