def test_invite_success(self, mock_relationship, mock_is_connected, mock_connect, mock_invite): user = UserNode() user.uid = 'abc' target_user = UserNode() target_user.uid = 'def' task = TaskInst(roles=['teacher']) task.tid = 'xyz' user.invite(task, target_user, role='teacher') mock_connect.assert_called_once_with(task, { 'role': 'teacher', 'super_role': SUPER_ROLE.STANDARD }) mock_invite.assert_called_once_with( [target_user.uid], inviter_id=user.uid, task_id=task.tid)
def test_invite_not_admin(self, mock_relationship): user = UserNode() target_user = UserNode() task = TaskInst() with self.assertRaises(NotAdmin): user.invite(task, target_user)
def test_invite_task_has_no_role(self, mock_relationship): user = UserNode() target_user = UserNode() task = TaskInst() with self.assertRaises(NoSuchRole): user.invite(task, target_user, role='teacher')
def test_invite_user_already_has_task(self, mock_relationship, mock_is_connected): user = UserNode() target_user = UserNode() task = TaskInst(roles=['teacher']) with self.assertRaises(AlreadyHasTheTask): user.invite(task, target_user, role='teacher')