mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Fix for create job id on api side
This commit is contained in:
@@ -198,7 +198,7 @@ class Notification(db.Model):
|
|||||||
|
|
||||||
__tablename__ = 'notifications'
|
__tablename__ = 'notifications'
|
||||||
|
|
||||||
id = db.Column(UUID(as_uuid=True), primary_key=True)
|
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||||
to = db.Column(db.String, nullable=False)
|
to = db.Column(db.String, nullable=False)
|
||||||
job_id = db.Column(UUID(as_uuid=True), db.ForeignKey('jobs.id'), index=True, unique=False, nullable=False)
|
job_id = db.Column(UUID(as_uuid=True), db.ForeignKey('jobs.id'), index=True, unique=False, nullable=False)
|
||||||
job = db.relationship('Job', backref=db.backref('notifications', lazy='dynamic'))
|
job = db.relationship('Job', backref=db.backref('notifications', lazy='dynamic'))
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import uuid
|
|
||||||
|
|
||||||
from app.models import Notification
|
from app.models import Notification
|
||||||
|
|
||||||
from app.dao.notifications_dao import (
|
from app.dao.notifications_dao import (
|
||||||
@@ -12,11 +10,8 @@ from app.dao.notifications_dao import (
|
|||||||
def test_save_notification(notify_db, notify_db_session, sample_template, sample_job):
|
def test_save_notification(notify_db, notify_db_session, sample_template, sample_job):
|
||||||
|
|
||||||
assert Notification.query.count() == 0
|
assert Notification.query.count() == 0
|
||||||
|
|
||||||
notification_id = uuid.uuid4()
|
|
||||||
to = '+44709123456'
|
to = '+44709123456'
|
||||||
data = {
|
data = {
|
||||||
'id': notification_id,
|
|
||||||
'to': to,
|
'to': to,
|
||||||
'job': sample_job,
|
'job': sample_job,
|
||||||
'service': sample_template.service,
|
'service': sample_template.service,
|
||||||
@@ -27,10 +22,8 @@ def test_save_notification(notify_db, notify_db_session, sample_template, sample
|
|||||||
save_notification(notification)
|
save_notification(notification)
|
||||||
|
|
||||||
assert Notification.query.count() == 1
|
assert Notification.query.count() == 1
|
||||||
|
notification_from_db = Notification.query.all()[0]
|
||||||
notification_from_db = Notification.query.get(notification_id)
|
assert notification_from_db.id
|
||||||
|
|
||||||
assert data['id'] == notification_from_db.id
|
|
||||||
assert data['to'] == notification_from_db.to
|
assert data['to'] == notification_from_db.to
|
||||||
assert data['job'] == notification_from_db.job
|
assert data['job'] == notification_from_db.job
|
||||||
assert data['service'] == notification_from_db.service
|
assert data['service'] == notification_from_db.service
|
||||||
|
|||||||
@@ -219,10 +219,8 @@ def test_get_notifications(notify_api, notify_db, notify_db_session, sample_job)
|
|||||||
|
|
||||||
def test_add_notification(notify_api, notify_db, notify_db_session, sample_job):
|
def test_add_notification(notify_api, notify_db, notify_db_session, sample_job):
|
||||||
|
|
||||||
notificaton_id = uuid.uuid4()
|
|
||||||
to = '+44709123456'
|
to = '+44709123456'
|
||||||
data = {
|
data = {
|
||||||
'id': str(notificaton_id),
|
|
||||||
'to': to,
|
'to': to,
|
||||||
'job': str(sample_job.id),
|
'job': str(sample_job.id),
|
||||||
'service': str(sample_job.service.id),
|
'service': str(sample_job.service.id),
|
||||||
@@ -245,7 +243,7 @@ def test_add_notification(notify_api, notify_db, notify_db_session, sample_job):
|
|||||||
|
|
||||||
resp_json = json.loads(response.get_data(as_text=True))
|
resp_json = json.loads(response.get_data(as_text=True))
|
||||||
|
|
||||||
assert data['id'] == resp_json['data']['id']
|
assert resp_json['data']['id']
|
||||||
assert data['to'] == resp_json['data']['to']
|
assert data['to'] == resp_json['data']['to']
|
||||||
assert data['service'] == resp_json['data']['service']
|
assert data['service'] == resp_json['data']['service']
|
||||||
assert data['template'] == resp_json['data']['template']
|
assert data['template'] == resp_json['data']['template']
|
||||||
|
|||||||
Reference in New Issue
Block a user