Exemplo n.º 1
0
 def test_shouldNotifyUserWhenHeIsSubscribedToQueue(self):
     branch = self._config.get_branches()[0]
     self._merge_dispatcher.subscribe(self._first_user_id, branch)
     self._notifier.reset_mock()
     self._merge_dispatcher.merge(self._second_user_id, branch)
     self._merge_dispatcher.merge(self._third_user_id, branch)
     self._notifier.notify.assert_any_call(
         self._model.get_user(self._first_user_id),
         NotifierActions.starts_merge,
         Notifier.ActionData(self._model.get_user(self._second_user_id),
                             branch))
     self._notifier.notify.assert_any_call(
         self._model.get_user(self._first_user_id),
         NotifierActions.joins_queue,
         Notifier.ActionData(self._model.get_user(self._third_user_id),
                             branch))
 def test_shouldSendMessageIfUserReadyToMerge(self):
     self._presentation_model.notify(
         self._whom_user, NotifierActions.ready_to_merge,
         Notifier.ActionData(self._whom_user, self._branch))
     message = str.format(Messages.ACTION_MESSAGE_YOUR_MERGE_TURN,
                          self._branch)
     self._message_sender.request_merge_confirmation.assert_called_once_with(
         self._whom_user_id, message, self._branch)
 def test_shouldSendMessageIfMergeStartedBySameUserAsSender(self):
     self._presentation_model.notify(
         self._whom_user, NotifierActions.starts_merge,
         Notifier.ActionData(self._whom_user, self._branch))
     message = str.format(Messages.ACTION_MESSAGE_STARTED_MERGE,
                          self._branch)
     self._message_sender.send.assert_called_once_with(
         self._whom_user_id, message)
 def test_shouldSendMessageIfUserFinishedMerge(self):
     self._presentation_model.notify(
         self._whom_user, NotifierActions.done_merge,
         Notifier.ActionData(self._action_user, self._branch))
     message = self.generate_message(self._action_user, self._branch,
                                     NotifierActions.done_merge)
     self._message_sender.send.assert_called_once_with(
         self._whom_user_id, message)
Exemplo n.º 5
0
 def test_shouldNotifyWhenUserJoinsQueue(self):
     branch = self._config.get_branches()[0]
     self._merge_dispatcher.merge(self._first_user_id, branch)
     self._notifier.reset_mock()
     self._merge_dispatcher.merge(self._second_user_id, branch)
     self._notifier.notify.assert_any_call(
         self._model.get_user(self._first_user_id),
         NotifierActions.joins_queue,
         Notifier.ActionData(self._model.get_user(self._second_user_id),
                             branch))
Exemplo n.º 6
0
 def test_shouldNotifyWhenUserExitsQueue(self):
     branch = self._config.get_branches()[0]
     self._merge_dispatcher.merge(self._first_user_id, branch)
     self._merge_dispatcher.merge(self._second_user_id, branch)
     self._notifier.reset_mock()
     self._merge_dispatcher.cancel(self._second_user_id, branch)
     self._notifier.notify.assert_called_once_with(
         self._model.get_user(self._first_user_id),
         NotifierActions.exits_queue,
         Notifier.ActionData(self._model.get_user(self._second_user_id),
                             branch))
Exemplo n.º 7
0
 def test_shouldNotifyIfUserStartsMergeWhenHeIsNext(self):
     branch = self._config.get_branches()[0]
     self._merge_dispatcher.merge(self._first_user_id, branch)
     self._merge_dispatcher.merge(self._second_user_id, branch)
     self._merge_dispatcher.merge(self._third_user_id, branch)
     self._merge_dispatcher.cancel(self._first_user_id, branch)
     self._merge_dispatcher.confirm_merge(self._second_user_id, branch)
     self._notifier.notify.assert_any_call(
         self._model.get_user(self._third_user_id),
         NotifierActions.starts_merge,
         Notifier.ActionData(self._model.get_user(self._second_user_id),
                             branch))
Exemplo n.º 8
0
 def test_shouldNotifyWhenNextUserFromQueueReadyToMergeAfterDone(self):
     branch = self._config.get_branches()[0]
     self._merge_dispatcher.merge(self._first_user_id, branch)
     self._merge_dispatcher.merge(self._second_user_id, branch)
     self._merge_dispatcher.merge(self._third_user_id, branch)
     self._notifier.reset_mock()
     self._merge_dispatcher.done(self._first_user_id, branch)
     self._notifier.notify.assert_any_call(
         self._model.get_user(self._second_user_id),
         NotifierActions.ready_to_merge,
         Notifier.ActionData(self._model.get_user(self._second_user_id),
                             branch))
Exemplo n.º 9
0
 def test_shouldNotifyOnPrepareWhenNoActiveUserBurUserInQueue(self):
     branch = self._config.get_branches()[0]
     self._merge_dispatcher.merge(self._first_user_id, branch)
     self._merge_dispatcher.merge(self._second_user_id, branch)
     self._merge_dispatcher.merge(self._third_user_id, branch)
     self._merge_dispatcher.done(self._first_user_id, branch)
     self._notifier.reset_mock()
     self._merge_dispatcher.prepare()
     self._notifier.notify.assert_any_call(
         self._model.get_user(self._second_user_id),
         NotifierActions.ready_to_merge,
         Notifier.ActionData(self._model.get_user(self._second_user_id),
                             branch))
Exemplo n.º 10
0
 def test_shouldNotifyWhenUserExitsQueueAndNoActiveUser(self):
     branch = self._config.get_branches()[0]
     self._merge_dispatcher.merge(self._first_user_id, branch)
     self._merge_dispatcher.merge(self._second_user_id, branch)
     self._merge_dispatcher.merge(self._third_user_id, branch)
     self._merge_dispatcher.cancel(self._first_user_id, branch)
     self._notifier.reset_mock()
     self._merge_dispatcher.cancel(self._second_user_id, branch)
     self._notifier.notify.assert_any_call(
         self._model.get_user(self._third_user_id),
         NotifierActions.ready_to_merge,
         Notifier.ActionData(self._model.get_user(self._third_user_id),
                             branch))
 def test_shouldNotSendMessageIfSameUserAsSenderFinishedMerge(self):
     self._presentation_model.notify(
         self._whom_user, NotifierActions.done_merge,
         Notifier.ActionData(self._whom_user, self._branch))
     self._message_sender.send.assert_not_called()
 def test_shouldNotSendMessageIfSameUserAsSenderExitsQueue(self):
     self._presentation_model.notify(
         self._whom_user, NotifierActions.exits_queue,
         Notifier.ActionData(self._whom_user, self._branch))
     self._message_sender.send.assert_not_called()
 def test_shouldNotSendMessageIfUserReadyToMerge(self):
     self._presentation_model.notify(
         self._whom_user, NotifierActions.ready_to_merge,
         Notifier.ActionData(self._action_user, self._branch))
     self._message_sender.send.assert_not_called()