mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
Work in progress, skeleton of the api created and testing started. Need to fix authentication tests.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
from app.main.dao.users_dao import (create_user, get_users)
|
||||
from app.main.dao.services_dao import (create_service, get_services)
|
||||
from app.dao.users_dao import (create_user, get_users)
|
||||
from app.dao.services_dao import (create_service, get_services)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from app.main.dao.services_dao import (create_service, get_services)
|
||||
from app.dao.services_dao import (create_service, get_services)
|
||||
from tests.app.conftest import sample_service as create_sample_service
|
||||
from app.models import Service
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from app.main.dao.users_dao import (create_user, get_users)
|
||||
from sqlalchemy.exc import DataError
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
from app.dao.users_dao import (create_user, get_users)
|
||||
from tests.app.conftest import sample_user as create_sample_user
|
||||
from app.models import User
|
||||
|
||||
@@ -28,3 +30,19 @@ def test_get_user(notify_api, notify_db, notify_db_session):
|
||||
notify_db_session,
|
||||
email=email)
|
||||
assert get_users(user_id=another_user.id).email_address == email
|
||||
|
||||
|
||||
def test_get_user_not_exists(notify_api, notify_db, notify_db_session):
|
||||
try:
|
||||
get_users(user_id="12345")
|
||||
pytest.fail("NoResultFound exception not thrown.")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def test_get_user_invalid_id(notify_api, notify_db, notify_db_session):
|
||||
try:
|
||||
get_users(user_id="blah")
|
||||
pytest.fail("DataError exception not thrown.")
|
||||
except DataError:
|
||||
pass
|
||||
0
tests/app/service/__init__.py
Normal file
0
tests/app/service/__init__.py
Normal file
0
tests/app/service/views/__init__.py
Normal file
0
tests/app/service/views/__init__.py
Normal file
33
tests/app/service/views/test_rest.py
Normal file
33
tests/app/service/views/test_rest.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import json
|
||||
from flask import url_for
|
||||
|
||||
|
||||
def test_get_service_list(notify_api, notify_db, notify_db_session, sample_service):
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
response = client.get(url_for('service.get_service'))
|
||||
assert response.status_code == 200
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
# TODO assert correct json returned
|
||||
assert len(json_resp['data']) == 1
|
||||
assert json_resp['data'][0]['name'] == sample_service.name
|
||||
assert json_resp['data'][0]['id'] == sample_service.id
|
||||
|
||||
|
||||
def test_get_service(notify_api, notify_db, notify_db_session, sample_service):
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
resp = client.get(url_for('service.get_service',
|
||||
service_id=sample_service.id))
|
||||
assert resp.status_code == 200
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
assert json_resp['data']['name'] == sample_service.name
|
||||
assert json_resp['data']['id'] == sample_service.id
|
||||
|
||||
|
||||
def test_post_service(notify_api, notify_db, notify_db_session, sample_service):
|
||||
pass
|
||||
|
||||
|
||||
def test_put_service(notify_api, notify_db, notify_db_session, sample_service):
|
||||
pass
|
||||
0
tests/app/user/__init__.py
Normal file
0
tests/app/user/__init__.py
Normal file
0
tests/app/user/views/__init__.py
Normal file
0
tests/app/user/views/__init__.py
Normal file
0
tests/app/user/views/test_rest.py
Normal file
0
tests/app/user/views/test_rest.py
Normal file
Reference in New Issue
Block a user