示例#1
0
 def test_exploration_rights_change_object_with_invalid_role(self):
     with self.assertRaisesRegexp(utils.ValidationError,
                                  ('Value for new_role in cmd change_role: '
                                   'invalid is not allowed')):
         rights_domain.ExplorationRightsChange({
             'cmd': 'change_role',
             'assignee_id': 'assignee_id',
             'old_role': rights_domain.ROLE_OWNER,
             'new_role': 'invalid',
         })
示例#2
0
 def test_exploration_rights_change_object_with_invalid_status(self):
     with self.assertRaisesRegexp(
             utils.ValidationError,
         ('Value for new_status in cmd change_exploration_status: '
          'invalid is not allowed')):
         rights_domain.ExplorationRightsChange({
             'cmd': 'change_exploration_status',
             'old_status': rights_domain.ACTIVITY_STATUS_PRIVATE,
             'new_status': 'invalid'
         })
示例#3
0
 def test_exploration_rights_change_object_with_missing_attribute_in_cmd(
         self):
     with self.assertRaisesRegexp(
             utils.ValidationError,
         ('The following required attributes are missing: '
          'new_role, old_role')):
         rights_domain.ExplorationRightsChange({
             'cmd': 'change_role',
             'assignee_id': 'assignee_id',
         })
示例#4
0
 def test_to_dict(self):
     exploration_rights_change_dict = {
         'cmd': 'change_private_viewability',
         'old_viewable_if_private': 'old_viewable_if_private',
         'new_viewable_if_private': 'new_viewable_if_private'
     }
     exploration_rights_change_object = (
         rights_domain.ExplorationRightsChange(
             exploration_rights_change_dict))
     self.assertEqual(exploration_rights_change_object.to_dict(),
                      exploration_rights_change_dict)
示例#5
0
 def test_exploration_rights_change_object_with_extra_attribute_in_cmd(
         self):
     with self.assertRaisesRegexp(
             utils.ValidationError,
         ('The following extra attributes are present: invalid')):
         rights_domain.ExplorationRightsChange({
             'cmd': 'change_private_viewability',
             'old_viewable_if_private': 'old_viewable_if_private',
             'new_viewable_if_private': 'new_viewable_if_private',
             'invalid': 'invalid'
         })
示例#6
0
    def test_exploration_rights_change_object_with_change_exploration_status(
            self) -> None:
        exploration_rights_change_object = (
            rights_domain.ExplorationRightsChange(
                {  # type: ignore[no-untyped-call]
                    'cmd': 'change_exploration_status',
                    'old_status': rights_domain.ACTIVITY_STATUS_PRIVATE,
                    'new_status': rights_domain.ACTIVITY_STATUS_PUBLIC
                }))

        self.assertEqual(exploration_rights_change_object.cmd,
                         'change_exploration_status')
        self.assertEqual(exploration_rights_change_object.old_status,
                         rights_domain.ACTIVITY_STATUS_PRIVATE)
        self.assertEqual(exploration_rights_change_object.new_status,
                         rights_domain.ACTIVITY_STATUS_PUBLIC)
示例#7
0
    def test_exploration_rights_change_object_with_change_role(self) -> None:
        exploration_rights_change_object = (
            rights_domain.ExplorationRightsChange(
                {  # type: ignore[no-untyped-call]
                    'cmd': 'change_role',
                    'assignee_id': 'assignee_id',
                    'old_role': rights_domain.ROLE_OWNER,
                    'new_role': rights_domain.ROLE_VIEWER
                }))

        self.assertEqual(exploration_rights_change_object.cmd, 'change_role')
        self.assertEqual(exploration_rights_change_object.assignee_id,
                         'assignee_id')
        self.assertEqual(exploration_rights_change_object.old_role,
                         rights_domain.ROLE_OWNER)
        self.assertEqual(exploration_rights_change_object.new_role,
                         rights_domain.ROLE_VIEWER)
示例#8
0
    def test_exploration_rights_change_object_with_update_first_published_msec(
            self) -> None:
        exploration_rights_change_object = (
            rights_domain.ExplorationRightsChange(
                {  # type: ignore[no-untyped-call]
                    'cmd': 'update_first_published_msec',
                    'old_first_published_msec': 'old_first_published_msec',
                    'new_first_published_msec': 'new_first_published_msec'
                }))

        self.assertEqual(exploration_rights_change_object.cmd,
                         'update_first_published_msec')
        self.assertEqual(
            exploration_rights_change_object.old_first_published_msec,
            'old_first_published_msec')
        self.assertEqual(
            exploration_rights_change_object.new_first_published_msec,
            'new_first_published_msec')
示例#9
0
    def test_exploration_rights_change_object_with_change_private_viewability(
            self):
        exploration_rights_change_object = (
            rights_domain.ExplorationRightsChange({
                'cmd': 'change_private_viewability',
                'old_viewable_if_private': 'old_viewable_if_private',
                'new_viewable_if_private': 'new_viewable_if_private'
            })
        )

        self.assertEqual(
            exploration_rights_change_object.cmd, 'change_private_viewability')
        self.assertEqual(
            exploration_rights_change_object.old_viewable_if_private,
            'old_viewable_if_private')
        self.assertEqual(
            exploration_rights_change_object.new_viewable_if_private,
            'new_viewable_if_private')
示例#10
0
    def test_exploration_rights_change_object_with_change_private_viewability(
            self) -> None:
        exploration_rights_change_object = (
            rights_domain.ExplorationRightsChange(
                {  # type: ignore[no-untyped-call]
                    'cmd': 'change_private_viewability',
                    'old_viewable_if_private': 'old_viewable_if_private',
                    'new_viewable_if_private': 'new_viewable_if_private'
                }))

        self.assertEqual(exploration_rights_change_object.cmd,
                         'change_private_viewability')
        self.assertEqual(
            exploration_rights_change_object.old_viewable_if_private,
            'old_viewable_if_private')
        self.assertEqual(
            exploration_rights_change_object.new_viewable_if_private,
            'new_viewable_if_private')
示例#11
0
    def test_exploration_rights_change_object_with_update_first_published_msec(
            self):
        exploration_rights_change_object = (
            rights_domain.ExplorationRightsChange({
                'cmd': 'update_first_published_msec',
                'old_first_published_msec': 'old_first_published_msec',
                'new_first_published_msec': 'new_first_published_msec'
            })
        )

        self.assertEqual(
            exploration_rights_change_object.cmd, 'update_first_published_msec')
        self.assertEqual(
            exploration_rights_change_object.old_first_published_msec,
            'old_first_published_msec')
        self.assertEqual(
            exploration_rights_change_object.new_first_published_msec,
            'new_first_published_msec')
示例#12
0
    def test_exploration_rights_change_object_with_create_new(self):
        exploration_rights_change_object = (
            rights_domain.ExplorationRightsChange({'cmd': 'create_new'}))

        self.assertEqual(exploration_rights_change_object.cmd, 'create_new')
示例#13
0
 def test_exploration_rights_change_object_with_invalid_cmd(self):
     with self.assertRaisesRegexp(utils.ValidationError,
                                  'Command invalid is not allowed'):
         rights_domain.ExplorationRightsChange({'cmd': 'invalid'})
示例#14
0
 def test_exploration_rights_change_object_with_missing_cmd(self):
     with self.assertRaisesRegexp(utils.ValidationError,
                                  'Missing cmd key in change dict'):
         rights_domain.ExplorationRightsChange({'invalid': 'data'})
示例#15
0
 def test_exploration_rights_change_object_with_invalid_cmd(self) -> None:
     with self.assertRaisesRegex(  # type: ignore[no-untyped-call]
             utils.ValidationError, 'Command invalid is not allowed'):
         rights_domain.ExplorationRightsChange({'cmd': 'invalid'})
示例#16
0
 def test_exploration_rights_change_object_with_missing_cmd(self) -> None:
     with self.assertRaisesRegex(  # type: ignore[no-untyped-call]
             utils.ValidationError, 'Missing cmd key in change dict'):
         rights_domain.ExplorationRightsChange({'invalid': 'data'})
示例#17
0
    def test_exploration_rights_change_object_with_create_new(self) -> None:
        exploration_rights_change_object = (
            rights_domain.ExplorationRightsChange({'cmd': 'create_new'})
        )  # type: ignore[no-untyped-call]

        self.assertEqual(exploration_rights_change_object.cmd, 'create_new')