-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(service_feedback): adding tests for oncall service feedback (#5386)
- Loading branch information
Showing
4 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
def test_create(session, case, case_type, case_priority): | ||
from dispatch.feedback.incident.service import create | ||
from dispatch.feedback.incident.models import FeedbackCreate | ||
|
||
case.incident_type = case_type | ||
case.incident_priority = case_priority | ||
rating = "Neither satisfied nor dissatisfied" | ||
feedback = "The incident commander did an excellent job" | ||
|
||
feedback_in = FeedbackCreate(rating=rating, feedback=feedback, case=case) | ||
feedback = create(db_session=session, feedback_in=feedback_in) | ||
assert feedback | ||
|
||
|
||
def test_get(session, feedback): | ||
from dispatch.feedback.incident.service import get | ||
|
||
t_feedback = get(db_session=session, feedback_id=feedback.id) | ||
assert t_feedback.id == feedback.id | ||
|
||
|
||
def test_get_all(session, feedbacks): | ||
from dispatch.feedback.incident.service import get_all | ||
|
||
t_feedbacks = get_all(db_session=session).all() | ||
assert t_feedbacks | ||
|
||
|
||
def test_update(session, feedback): | ||
from dispatch.feedback.incident.service import update | ||
from dispatch.feedback.incident.models import FeedbackUpdate | ||
|
||
rating = "Very satisfied" | ||
feedback_text = "The incident commander did an excellent job" | ||
|
||
feedback_in = FeedbackUpdate(rating=rating, feedback=feedback_text) | ||
feedback = update(db_session=session, feedback=feedback, feedback_in=feedback_in) | ||
|
||
assert feedback.rating == rating | ||
assert feedback.feedback == feedback_text | ||
|
||
|
||
def test_delete(session, feedback): | ||
from dispatch.feedback.incident.service import delete, get | ||
|
||
delete(db_session=session, feedback_id=feedback.id) | ||
assert not get(db_session=session, feedback_id=feedback.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" Tests oncall service feedback """ | ||
|
||
|
||
def test_create(session, participant, project): | ||
from dispatch.feedback.service.service import create | ||
from dispatch.feedback.service.models import ServiceFeedbackCreate | ||
|
||
feedback = "Not a difficult shift" | ||
hours = 5 | ||
rating = "No effort" | ||
|
||
feedback_in = ServiceFeedbackCreate( | ||
individual=participant.individual, | ||
rating=rating, | ||
feedback=feedback, | ||
hours=hours, | ||
project=project, | ||
) | ||
feedback = create(db_session=session, service_feedback_in=feedback_in) | ||
assert feedback | ||
|
||
|
||
def test_get(session, service_feedback): | ||
from dispatch.feedback.service.service import get | ||
|
||
t_feedback = get(db_session=session, service_feedback_id=service_feedback.id) | ||
assert t_feedback.id == service_feedback.id | ||
|
||
|
||
def test_get_all(session): | ||
from dispatch.feedback.service.service import get_all | ||
|
||
t_feedbacks = get_all(db_session=session).all() | ||
assert t_feedbacks | ||
|
||
|
||
def test_update(session, service_feedback): | ||
from dispatch.feedback.service.service import update | ||
from dispatch.feedback.service.models import ServiceFeedbackUpdate | ||
|
||
feedback_text = "Changed my mind. The shift was difficult" | ||
|
||
feedback_in = ServiceFeedbackUpdate(id=service_feedback.id, feedback=feedback_text) | ||
feedback = update( | ||
db_session=session, service_feedback=service_feedback, service_feedback_in=feedback_in | ||
) | ||
|
||
assert feedback.feedback == feedback_text | ||
|
||
|
||
def test_delete(session, service_feedback): | ||
from dispatch.feedback.service.service import delete, get | ||
|
||
delete(db_session=session, service_feedback_id=service_feedback.id) | ||
assert not get(db_session=session, service_feedback_id=service_feedback.id) |