コード例 #1
0
    def test_get_all_actions(self) -> None:
        with self.assertRaisesRegex(  # type: ignore[no-untyped-call]
                Exception, 'Role TEST_ROLE does not exist.'):
            role_services.get_all_actions(['TEST_ROLE'])

        self.assertEqual(role_services.get_all_actions([feconf.ROLE_ID_GUEST]),
                         [role_services.ACTION_PLAY_ANY_PUBLIC_ACTIVITY])
コード例 #2
0
    def test_get_all_actions(self):
        with self.assertRaisesRegexp(Exception,
                                     'Role TEST_ROLE does not exist.'):
            role_services.get_all_actions(['TEST_ROLE'])

        self.assertEqual(role_services.get_all_actions([feconf.ROLE_ID_GUEST]),
                         [role_services.ACTION_PLAY_ANY_PUBLIC_ACTIVITY])
コード例 #3
0
ファイル: role_services_test.py プロジェクト: timusp/oppia
    def test_get_all_actions(self):
        """Test that get_all_actions works as expected."""

        # Case when wrong input is given.
        with self.assertRaisesRegexp(
            Exception, 'Role TEST_ROLE does not exist.'):
            role_services.get_all_actions('TEST_ROLE')

        # Case for collection editor is checked.
        collection_editor_actions = list(
            set(role_services.ROLE_ACTIONS[feconf.ROLE_ID_EXPLORATION_EDITOR]) |
            set(role_services.ROLE_ACTIONS[feconf.ROLE_ID_BANNED_USER]) |
            set(role_services.ROLE_ACTIONS[feconf.ROLE_ID_GUEST]) |
            set(role_services.ROLE_ACTIONS[feconf.ROLE_ID_COLLECTION_EDITOR]))

        # Sets are compared as their element order don't need to be same.
        self.assertEqual(set(collection_editor_actions),
                         set(role_services.get_all_actions(
                             feconf.ROLE_ID_COLLECTION_EDITOR)))