Ejemplo n.º 1
0
 def test_change_invitation_change_role(self, mock_save):
     mock_owner_has_task = HasTask(super_role=SUPER_ROLE.OWNER, acceptance=ACCEPTANCE.ACCEPT)
     mock_user_has_task = HasTask(super_role=SUPER_ROLE.OWNER, acceptance=ACCEPTANCE.ACCEPT)
     user = UserNode()
     task = TaskInst(roles=['teacher'])
     target_user = UserNode()
     user.tasks.relationship = MagicMock(return_value=mock_owner_has_task)
     target_user.tasks.relationship = MagicMock(return_value=mock_user_has_task)
     user.change_invitation(task, target_user, role='teacher')
     self.assertEqual('teacher', mock_user_has_task.role)
     self.assertEqual(SUPER_ROLE.OWNER, mock_user_has_task.super_role)
Ejemplo n.º 2
0
 def test_change_invitation_change_super_role_admin(self, mock_save):
     mock_owner_has_task = HasTask(super_role=SUPER_ROLE.OWNER, acceptance=ACCEPTANCE.ACCEPT)
     mock_user_has_task = HasTask(super_role=SUPER_ROLE.STANDARD, acceptance=ACCEPTANCE.ACCEPT)
     user = UserNode()
     task = TaskInst()
     target_user = UserNode()
     user.tasks.relationship = MagicMock(return_value=mock_owner_has_task)
     target_user.tasks.relationship = MagicMock(return_value=mock_user_has_task)
     user.change_invitation(task, target_user, super_role=SUPER_ROLE.ADMIN)
     self.assertEqual(SUPER_ROLE.ADMIN, mock_user_has_task.super_role)
     self.assertEqual(SUPER_ROLE.OWNER, mock_owner_has_task.super_role)
Ejemplo n.º 3
0
 def test_change_invitation_not_owner(self, mock_relationship):
     user = UserNode()
     task = TaskInst()
     target_user = UserNode()
     with self.assertRaises(NotOwner):
         user.change_invitation(task, target_user, super_role=SUPER_ROLE.ADMIN)
Ejemplo n.º 4
0
 def test_change_invitation_has_no_role(self, mock_relationship):
     user = UserNode()
     task = TaskInst()
     target_user = UserNode()
     with self.assertRaises(NoSuchRole):
         user.change_invitation(task, target_user, role='teacher')