mirror of
https://github.com/GSA/notifications-api.git
synced 2026-04-20 17:29:54 -04:00
Add queue name to service table.
Set queue name when creating the service
This commit is contained in:
@@ -84,7 +84,7 @@ class Service(db.Model):
|
||||
secondary=user_to_service,
|
||||
backref=db.backref('user_to_service', lazy='dynamic'))
|
||||
restricted = db.Column(db.Boolean, index=False, unique=False, nullable=False)
|
||||
|
||||
queue_name = db.Column(UUID(as_uuid=True))
|
||||
|
||||
class ApiKey(db.Model):
|
||||
__tablename__ = 'api_key'
|
||||
|
||||
@@ -28,6 +28,9 @@ def create_service():
|
||||
# I believe service is already added to the session but just needs a
|
||||
# db.session.commit
|
||||
try:
|
||||
# add service name to here or in dao?
|
||||
import uuid
|
||||
service.queue_name = uuid.uuid4()
|
||||
save_model_service(service)
|
||||
except DAOException as e:
|
||||
return jsonify(result="error", message=str(e)), 400
|
||||
|
||||
26
migrations/versions/0010_add_queue_name_to_service.py
Normal file
26
migrations/versions/0010_add_queue_name_to_service.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0010_add_queue_name_to_service
|
||||
Revises: 0009_unique_service_to_key_name
|
||||
Create Date: 2016-01-27 13:53:34.717916
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
|
||||
revision = '0010_add_queue_name_to_service'
|
||||
down_revision = '0009_unique_service_to_key_name'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('services', sa.Column('queue_name', postgresql.UUID(as_uuid=True), nullable=True))
|
||||
### end Alembic commands ###
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('services', 'queue_name')
|
||||
### end Alembic commands ###
|
||||
@@ -1,4 +1,6 @@
|
||||
import pytest
|
||||
from flask import jsonify
|
||||
|
||||
from app.models import (User, Service, Template, ApiKey, Job, VerifyCode)
|
||||
from app.dao.users_dao import (save_model_user, create_user_code, create_secret_code)
|
||||
from app.dao.services_dao import save_model_service
|
||||
@@ -156,7 +158,7 @@ def sample_admin_service_id(notify_db, notify_db_session):
|
||||
@pytest.fixture(scope='function')
|
||||
def mock_notify_client_send_sms(mocker):
|
||||
def _send(mobile_number, message):
|
||||
pass
|
||||
return jsonify('sms sent'), 200
|
||||
|
||||
mock_class = mocker.patch('app.notify_alpha_client.send_sms', side_effect=_send)
|
||||
return mock_class
|
||||
|
||||
@@ -93,6 +93,7 @@ def test_post_service(notify_api, notify_db, notify_db_session, sample_user, sam
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
assert json_resp['data']['name'] == service.name
|
||||
assert json_resp['data']['limit'] == service.limit
|
||||
assert service.queue_name is not None
|
||||
|
||||
|
||||
def test_post_service_multiple_users(notify_api, notify_db, notify_db_session, sample_user, sample_admin_service_id):
|
||||
|
||||
Reference in New Issue
Block a user