Automatically associate new service with an org

This is the same thing we do in the admin app at the moment with YAML:
2f4e933b65/app/utils.py (L556-L562)
This commit is contained in:
Chris Hill-Scott
2019-02-19 12:02:18 +00:00
parent d7e03e00d3
commit c0fb9267bd
6 changed files with 131 additions and 6 deletions

View File

@@ -4,7 +4,7 @@ from datetime import datetime
import pytest
from freezegun import freeze_time
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm.exc import FlushError, NoResultFound
from sqlalchemy.orm.exc import NoResultFound
from app import db
from app.dao.inbound_numbers_dao import (
@@ -167,9 +167,9 @@ def test_cannot_create_service_with_no_user(notify_db_session):
message_limit=1000,
restricted=False,
created_by=user)
with pytest.raises(FlushError) as excinfo:
with pytest.raises(ValueError) as excinfo:
dao_create_service(service, None)
assert "Can't flush None value found in collection Service.users" in str(excinfo.value)
assert "Can't create a service without a user" in str(excinfo.value)
def test_should_add_user_to_service(notify_db_session):