mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 21:48:49 -04:00
Merge branch 'master' into client-callbacks
Conflicts: app/notifications/rest.py tests/app/celery/test_tasks.py
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
from datetime import datetime, timedelta
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
from app import db
|
||||
|
||||
from app.models import InvitedUser
|
||||
@@ -50,8 +54,9 @@ def test_get_invited_user_by_id(notify_db, notify_db_session, sample_invited_use
|
||||
def test_get_unknown_invited_user_returns_none(notify_db, notify_db_session, sample_service):
|
||||
unknown_id = uuid.uuid4()
|
||||
|
||||
unknown = get_invited_user(sample_service.id, unknown_id)
|
||||
assert unknown is None
|
||||
with pytest.raises(NoResultFound) as e:
|
||||
get_invited_user(sample_service.id, unknown_id)
|
||||
assert 'No row was found for one()' in str(e.value)
|
||||
|
||||
|
||||
def test_get_invited_users_for_service(notify_db, notify_db_session, sample_service):
|
||||
|
||||
@@ -11,7 +11,7 @@ from app.dao.services_dao import (
|
||||
)
|
||||
from app.dao.users_dao import save_model_user
|
||||
from app.models import Service, User
|
||||
from sqlalchemy.orm.exc import FlushError
|
||||
from sqlalchemy.orm.exc import FlushError, NoResultFound
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
|
||||
@@ -145,7 +145,9 @@ def test_get_all_user_services_should_return_empty_list_if_no_services_for_user(
|
||||
|
||||
|
||||
def test_get_service_by_id_returns_none_if_no_service(notify_db):
|
||||
assert not dao_fetch_service_by_id(str(uuid.uuid4()))
|
||||
with pytest.raises(NoResultFound) as e:
|
||||
dao_fetch_service_by_id(str(uuid.uuid4()))
|
||||
assert 'No row was found for one()' in str(e)
|
||||
|
||||
|
||||
def test_get_service_by_id_returns_service(service_factory):
|
||||
@@ -169,4 +171,6 @@ def test_cannot_get_service_by_id_and_owned_by_different_user(service_factory, s
|
||||
save_model_user(new_user)
|
||||
service2 = service_factory.get('service 2', new_user)
|
||||
assert dao_fetch_service_by_id_and_user(service1.id, sample_user.id).name == 'service 1'
|
||||
assert not dao_fetch_service_by_id_and_user(service2.id, sample_user.id)
|
||||
with pytest.raises(NoResultFound) as e:
|
||||
dao_fetch_service_by_id_and_user(service2.id, sample_user.id)
|
||||
assert 'No row was found for one()' in str(e)
|
||||
|
||||
@@ -155,4 +155,6 @@ def test_get_template_by_id_and_service(notify_db, notify_db_session, sample_ser
|
||||
|
||||
|
||||
def test_get_template_by_id_and_service_returns_none_if_no_template(sample_service):
|
||||
assert not dao_get_template_by_id_and_service_id(template_id=999, service_id=sample_service.id)
|
||||
with pytest.raises(NoResultFound) as e:
|
||||
dao_get_template_by_id_and_service_id(template_id=999, service_id=sample_service.id)
|
||||
assert 'No row was found for one' in str(e.value)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from datetime import datetime, timedelta
|
||||
from sqlalchemy.exc import DataError
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
from app import db
|
||||
import pytest
|
||||
|
||||
@@ -55,7 +57,7 @@ def test_get_user_not_exists(notify_api, notify_db, notify_db_session):
|
||||
try:
|
||||
get_model_users(user_id="12345")
|
||||
pytest.fail("NoResultFound exception not thrown.")
|
||||
except:
|
||||
except NoResultFound as e:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user