<s> from __future__ import absolute_import <EOL> import json <EOL> import responses <EOL> from freight import notifiers <EOL> from freight . notifiers import NotifierEvent <EOL> from freight . models import TaskStatus <EOL> from freight . testutils import TestCase <EOL> class SentryNotifierBase ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . notifier = notifiers . get ( '<STR_LIT>' ) <EOL> self . user = self . create_user ( ) <EOL> self . repo = self . create_repo ( ) <EOL> self . app = self . create_app ( repository = self . repo ) <EOL> self . deploy_config = self . create_taskconfig ( app = self . app ) <EOL> self . task = self . create_task ( <EOL> app = self . app , <EOL> user = self . user , <EOL> status = TaskStatus . finished , <EOL> ) <EOL> self . deploy = self . create_deploy ( <EOL> app = self . app , <EOL> task = self . task , <EOL> ) <EOL> class SentryNotifierTest ( SentryNotifierBase ) : <EOL> @ responses . activate <EOL> def test_send_finished_task ( self ) : <EOL> responses . add ( responses . POST , '<STR_LIT>' ) <EOL> config = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . notifier . send_deploy ( self . deploy , self . task , config , NotifierEvent . TASK_FINISHED ) <EOL> call = responses . calls [ <NUM_LIT:0> ] <EOL> assert len ( responses . calls ) == <NUM_LIT:1> <EOL> assert responses . calls [ <NUM_LIT:0> ] . request . url == '<STR_LIT>' <EOL> body = responses . calls [ <NUM_LIT:0> ] . request . body <EOL> payload = json . loads ( body ) <EOL> assert payload <EOL> @ responses . activate <EOL> def test_send_started_task ( self ) : <EOL> responses . add ( responses . POST , '<STR_LIT>' ) <EOL> config = { '<STR_LIT>' : '<STR_LIT>' } <EOL> self . notifier . send_deploy ( self . deploy , self . task , config , NotifierEvent . TASK_STARTED ) <EOL> call = responses . calls [ <NUM_LIT:0> ] <EOL> assert len ( responses . calls ) == <NUM_LIT:1> <EOL> assert responses . calls [ <NUM_LIT:0> ] . request . url == '<STR_LIT>' <EOL> body = responses . calls [ <NUM_LIT:0> ] . request . body <EOL> payload = json . loads ( body ) <EOL> assert payload </s>
