def test_inviting_playtester_to_exploration(self): exp = exp_domain.Exploration.create_default_exploration(self.EXP_ID) exp_services.save_new_exploration(self.user_id_a, exp) exp_rights = rights_manager.get_exploration_rights(self.EXP_ID) self.assertFalse(rights_manager.check_can_access_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_edit_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_voiceover_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_save_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_delete_activity( self.user_b, exp_rights)) rights_manager.assign_role_for_exploration( self.user_a, self.EXP_ID, self.user_id_b, rights_domain.ROLE_VIEWER) exp_rights = rights_manager.get_exploration_rights(self.EXP_ID) self.assertTrue(rights_manager.check_can_access_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_edit_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_voiceover_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_save_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_delete_activity( self.user_b, exp_rights))
def test_newly_created_exploration(self): exp = exp_domain.Exploration.create_default_exploration(self.EXP_ID) exp_services.save_new_exploration(self.user_id_a, exp) exp_rights = rights_manager.get_exploration_rights(self.EXP_ID) self.assertTrue(rights_manager.check_can_access_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_edit_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_voiceover_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_save_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_delete_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_access_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_edit_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_voiceover_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_save_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_delete_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_access_activity( self.user_moderator, exp_rights)) self.assertFalse(rights_manager.check_can_edit_activity( self.user_moderator, exp_rights)) self.assertFalse(rights_manager.check_can_voiceover_activity( self.user_moderator, exp_rights)) self.assertFalse(rights_manager.check_can_save_activity( self.user_moderator, exp_rights)) self.assertFalse(rights_manager.check_can_delete_activity( self.user_moderator, exp_rights)) self.assertFalse(rights_manager.check_can_access_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_edit_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_voiceover_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_save_activity( self.user_b, exp_rights)) self.assertFalse(rights_manager.check_can_delete_activity( self.user_b, exp_rights))
def test_non_splash_page_demo_exploration(self): # Note: there is no difference between permissions for demo # explorations, whether or not they are on the splash page. exp_services.load_demo('3') rights_manager.release_ownership_of_exploration( self.system_user, '3') exp_rights = rights_manager.get_exploration_rights('3') self.assertTrue(rights_manager.check_can_access_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_edit_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_voiceover_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_save_activity( self.user_a, exp_rights)) self.assertFalse(rights_manager.check_can_delete_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_access_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_edit_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_voiceover_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_save_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_delete_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_access_activity( self.user_moderator, exp_rights)) self.assertTrue(rights_manager.check_can_edit_activity( self.user_moderator, exp_rights)) self.assertTrue(rights_manager.check_can_voiceover_activity( self.user_moderator, exp_rights)) self.assertTrue(rights_manager.check_can_save_activity( self.user_moderator, exp_rights)) self.assertTrue(rights_manager.check_can_delete_activity( self.user_moderator, exp_rights))
def test_demo_exploration(self): exp_services.load_demo('1') rights_manager.release_ownership_of_exploration( self.system_user, '1') exp_rights = rights_manager.get_exploration_rights('1') self.assertTrue(rights_manager.check_can_access_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_edit_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_voiceover_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_save_activity( self.user_a, exp_rights)) self.assertFalse(rights_manager.check_can_delete_activity( self.user_a, exp_rights)) self.assertTrue(rights_manager.check_can_access_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_edit_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_voiceover_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_save_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_delete_activity( self.user_admin, exp_rights)) self.assertTrue(rights_manager.check_can_access_activity( self.user_moderator, exp_rights)) self.assertTrue(rights_manager.check_can_edit_activity( self.user_moderator, exp_rights)) self.assertTrue(rights_manager.check_can_voiceover_activity( self.user_moderator, exp_rights)) self.assertTrue(rights_manager.check_can_save_activity( self.user_moderator, exp_rights)) self.assertTrue(rights_manager.check_can_delete_activity( self.user_moderator, exp_rights))
def test_cannot_save_activity_with_no_activity_rights(self): self.assertFalse( rights_manager.check_can_save_activity(self.owner, None))