mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-11 17:38:02 -04:00
Cleaning things up, trying to get tests to work.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from app.models import BRANDING_TYPES
|
||||
from app.enums import BrandType
|
||||
|
||||
post_create_email_branding_schema = {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
@@ -9,7 +9,7 @@ post_create_email_branding_schema = {
|
||||
"name": {"type": "string"},
|
||||
"text": {"type": ["string", "null"]},
|
||||
"logo": {"type": ["string", "null"]},
|
||||
"brand_type": {"enum": BRANDING_TYPES},
|
||||
"brand_type": {"enum": [e.value for e in BrandType]},
|
||||
},
|
||||
"required": ["name"],
|
||||
}
|
||||
@@ -23,7 +23,7 @@ post_update_email_branding_schema = {
|
||||
"name": {"type": ["string", "null"]},
|
||||
"text": {"type": ["string", "null"]},
|
||||
"logo": {"type": ["string", "null"]},
|
||||
"brand_type": {"enum": BRANDING_TYPES},
|
||||
"brand_type": {"enum": [e.value for e in BrandType]},
|
||||
},
|
||||
"required": [],
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ from marshmallow import (
|
||||
validates,
|
||||
validates_schema,
|
||||
)
|
||||
from marshmallow_sqlalchemy import field_for
|
||||
from marshmallow_sqlalchemy import auto_field, field_for
|
||||
from notifications_utils.recipients import (
|
||||
InvalidEmailError,
|
||||
InvalidPhoneError,
|
||||
@@ -464,7 +464,7 @@ class JobSchema(BaseSchema):
|
||||
processing_started = FlexibleDateTime()
|
||||
processing_finished = FlexibleDateTime()
|
||||
|
||||
job_status = field_for(models.JobStatus, "name", required=False)
|
||||
job_status = auto_field()
|
||||
|
||||
scheduled_for = FlexibleDateTime()
|
||||
service_name = fields.Nested(
|
||||
|
||||
@@ -8,8 +8,6 @@ Create Date: 2018-02-28 17:09:56.619803
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
from app.models import NORMAL
|
||||
|
||||
revision = "0172_deprioritise_examples"
|
||||
down_revision = "0171_add_org_invite_template"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Create Date: 2018-08-24 13:36:49.346156
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.models import BRANDING_ORG
|
||||
from app.enums import BrandType
|
||||
|
||||
revision = "0219_default_email_branding"
|
||||
down_revision = "0216_remove_colours"
|
||||
@@ -14,7 +14,7 @@ down_revision = "0216_remove_colours"
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
input_params = {"branding_org": BRANDING_ORG}
|
||||
input_params = {"branding_org": BrandType.ORG.value}
|
||||
conn.execute(
|
||||
text(
|
||||
"""
|
||||
|
||||
@@ -5,7 +5,8 @@ from app.dao.service_guest_list_dao import (
|
||||
dao_fetch_service_guest_list,
|
||||
dao_remove_service_guest_list,
|
||||
)
|
||||
from app.models import GuestListRecipientType, ServiceGuestList
|
||||
from app.enums import RecipientType
|
||||
from app.models import ServiceGuestList
|
||||
from tests.app.db import create_service
|
||||
|
||||
|
||||
@@ -21,7 +22,7 @@ def test_fetch_service_guest_list_ignores_other_service(sample_service_guest_lis
|
||||
|
||||
def test_add_and_commit_guest_list_contacts_saves_data(sample_service):
|
||||
guest_list = ServiceGuestList.from_string(
|
||||
sample_service.id, GuestListRecipientType.EMAIL, "foo@example.com"
|
||||
sample_service.id, RecipientType.EMAIL, "foo@example.com"
|
||||
)
|
||||
|
||||
dao_add_and_commit_guest_list_contacts([guest_list])
|
||||
@@ -37,10 +38,10 @@ def test_remove_service_guest_list_only_removes_for_my_service(notify_db_session
|
||||
dao_add_and_commit_guest_list_contacts(
|
||||
[
|
||||
ServiceGuestList.from_string(
|
||||
service_1.id, GuestListRecipientType.EMAIL, "service1@example.com"
|
||||
service_1.id, RecipientType.EMAIL, "service1@example.com"
|
||||
),
|
||||
ServiceGuestList.from_string(
|
||||
service_2.id, GuestListRecipientType.EMAIL, "service2@example.com"
|
||||
service_2.id, RecipientType.EMAIL, "service2@example.com"
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -24,8 +24,9 @@ from app.dao.users_dao import (
|
||||
update_user_password,
|
||||
user_can_be_archived,
|
||||
)
|
||||
from app.enums import AuthType
|
||||
from app.errors import InvalidRequest
|
||||
from app.models import EMAIL_AUTH_TYPE, User, VerifyCode
|
||||
from app.models import User, VerifyCode
|
||||
from tests.app.db import (
|
||||
create_permissions,
|
||||
create_service,
|
||||
@@ -229,7 +230,7 @@ def test_dao_archive_user(sample_user, sample_organization, fake_uuid):
|
||||
assert sample_user.get_permissions() == {}
|
||||
assert sample_user.services == []
|
||||
assert sample_user.organizations == []
|
||||
assert sample_user.auth_type == EMAIL_AUTH_TYPE
|
||||
assert sample_user.auth_type == AuthType.EMAIL
|
||||
assert sample_user.email_address == "_archived_2018-07-07_notify@digital.fake.gov"
|
||||
assert sample_user.mobile_number is None
|
||||
assert sample_user.current_session_id == uuid.UUID(
|
||||
|
||||
@@ -5,7 +5,8 @@ from flask import current_app, json
|
||||
from freezegun import freeze_time
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
|
||||
from app.models import INVITE_PENDING, Notification
|
||||
from app.enums import InvitedUserStatus
|
||||
from app.models import Notification
|
||||
from tests import create_admin_authorization_header
|
||||
from tests.app.db import create_invited_org_user
|
||||
|
||||
@@ -56,7 +57,7 @@ def test_create_invited_org_user(
|
||||
assert json_resp["data"]["organization"] == str(sample_organization.id)
|
||||
assert json_resp["data"]["email_address"] == email_address
|
||||
assert json_resp["data"]["invited_by"] == str(sample_user.id)
|
||||
assert json_resp["data"]["status"] == INVITE_PENDING
|
||||
assert json_resp["data"]["status"] == InvitedUserStatus.PENDING
|
||||
assert json_resp["data"]["id"]
|
||||
|
||||
notification = Notification.query.first()
|
||||
|
||||
@@ -7,7 +7,6 @@ import pytest
|
||||
from flask import current_app
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app.dao.permissions_dao import default_service_permissions
|
||||
from app.dao.service_user_dao import dao_get_service_user, dao_update_service_user
|
||||
from app.enums import AuthType, PermissionType
|
||||
from app.models import Notification, Permission, User
|
||||
@@ -28,7 +27,7 @@ def test_get_user_list(admin_request, sample_service):
|
||||
# it may have the notify user in the DB still :weary:
|
||||
assert len(json_resp["data"]) >= 1
|
||||
sample_user = sample_service.users[0]
|
||||
expected_permissions = default_service_permissions
|
||||
expected_permissions = PermissionType.defaults()
|
||||
fetched = next(x for x in json_resp["data"] if x["id"] == str(sample_user.id))
|
||||
|
||||
assert sample_user.name == fetched["name"]
|
||||
@@ -56,7 +55,7 @@ def test_get_user(admin_request, sample_service, sample_organization):
|
||||
sample_user.organizations = [sample_organization]
|
||||
json_resp = admin_request.get("user.get_user", user_id=sample_user.id)
|
||||
|
||||
expected_permissions = default_service_permissions
|
||||
expected_permissions = PermissionType.defaults()
|
||||
fetched = json_resp["data"]
|
||||
|
||||
assert fetched["id"] == str(sample_user.id)
|
||||
@@ -376,7 +375,7 @@ def test_get_user_by_email(admin_request, sample_service):
|
||||
|
||||
json_resp = admin_request.get("user.get_by_email", email=sample_user.email_address)
|
||||
|
||||
expected_permissions = default_service_permissions
|
||||
expected_permissions = PermissionType.defaults()
|
||||
fetched = json_resp["data"]
|
||||
|
||||
assert str(sample_user.id) == fetched["id"]
|
||||
|
||||
Reference in New Issue
Block a user