Example #1
0
    def test_collection_rights_change_object_with_create_new(self) -> None:
        collection_rights_change_object = rights_domain.CollectionRightsChange(
            {  # type: ignore[no-untyped-call]
                'cmd': 'create_new'
            })

        self.assertEqual(collection_rights_change_object.cmd, 'create_new')
    def test_collection_rights_change_object_with_release_ownership(
            self) -> None:
        collection_rights_change_object = rights_domain.CollectionRightsChange(
            {'cmd': 'release_ownership'})

        self.assertEqual(collection_rights_change_object.cmd,
                         'release_ownership')
Example #3
0
 def test_collection_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.CollectionRightsChange({
             'cmd': 'change_role',
             'assignee_id': 'assignee_id',
         })
Example #4
0
 def test_collection_rights_change_object_with_extra_attribute_in_cmd(self):
     with self.assertRaisesRegexp(
             utils.ValidationError,
         ('The following extra attributes are present: invalid')):
         rights_domain.CollectionRightsChange({
             'cmd': 'change_private_viewability',
             'old_viewable_if_private': 'old_viewable_if_private',
             'new_viewable_if_private': 'new_viewable_if_private',
             'invalid': 'invalid'
         })
Example #5
0
 def test_collection_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.CollectionRightsChange({
             'cmd': 'change_role',
             'assignee_id': 'assignee_id',
             'old_role': rights_domain.ROLE_OWNER,
             'new_role': 'invalid',
         })
Example #6
0
 def test_collection_rights_change_object_with_invalid_status(self):
     with self.assertRaisesRegexp(
             utils.ValidationError,
         ('Value for new_status in cmd change_collection_status: '
          'invalid is not allowed')):
         rights_domain.CollectionRightsChange({
             'cmd': 'change_collection_status',
             'old_status': rights_domain.ACTIVITY_STATUS_PRIVATE,
             'new_status': 'invalid'
         })
Example #7
0
 def test_to_dict(self):
     collection_rights_change_dict = {
         'cmd': 'change_private_viewability',
         'old_viewable_if_private': 'old_viewable_if_private',
         'new_viewable_if_private': 'new_viewable_if_private'
     }
     collection_rights_change_object = rights_domain.CollectionRightsChange(
         collection_rights_change_dict)
     self.assertEqual(collection_rights_change_object.to_dict(),
                      collection_rights_change_dict)
Example #8
0
 def test_to_dict(self) -> None:
     collection_rights_change_dict = {
         'cmd': 'change_private_viewability',
         'old_viewable_if_private': 'old_viewable_if_private',
         'new_viewable_if_private': 'new_viewable_if_private'
     }
     collection_rights_change_object = rights_domain.CollectionRightsChange(  # type: ignore[no-untyped-call]
         collection_rights_change_dict)
     self.assertEqual(
         collection_rights_change_object.to_dict(
         ),  # type: ignore[no-untyped-call]
         collection_rights_change_dict)
Example #9
0
    def test_collection_rights_change_object_with_change_role(self):
        collection_rights_change_object = rights_domain.CollectionRightsChange({
            'cmd': 'change_role',
            'assignee_id': 'assignee_id',
            'old_role': rights_domain.ROLE_OWNER,
            'new_role': rights_domain.ROLE_VIEWER
        })

        self.assertEqual(collection_rights_change_object.cmd, 'change_role')
        self.assertEqual(
            collection_rights_change_object.assignee_id, 'assignee_id')
        self.assertEqual(
            collection_rights_change_object.old_role, rights_domain.ROLE_OWNER)
        self.assertEqual(
            collection_rights_change_object.new_role, rights_domain.ROLE_VIEWER)
Example #10
0
    def test_collection_rights_change_object_with_update_first_published_msec(
            self):
        collection_rights_change_object = rights_domain.CollectionRightsChange({
            'cmd': 'update_first_published_msec',
            'old_first_published_msec': 'old_first_published_msec',
            'new_first_published_msec': 'new_first_published_msec'
        })

        self.assertEqual(
            collection_rights_change_object.cmd, 'update_first_published_msec')
        self.assertEqual(
            collection_rights_change_object.old_first_published_msec,
            'old_first_published_msec')
        self.assertEqual(
            collection_rights_change_object.new_first_published_msec,
            'new_first_published_msec')
Example #11
0
    def test_collection_rights_change_object_with_change_collection_status(
            self) -> None:
        collection_rights_change_object = (
            rights_domain.CollectionRightsChange(
                {  # type: ignore[no-untyped-call]
                    'cmd': 'change_collection_status',
                    'old_status': rights_domain.ACTIVITY_STATUS_PRIVATE,
                    'new_status': rights_domain.ACTIVITY_STATUS_PUBLIC
                }))

        self.assertEqual(collection_rights_change_object.cmd,
                         'change_collection_status')
        self.assertEqual(collection_rights_change_object.old_status,
                         rights_domain.ACTIVITY_STATUS_PRIVATE)
        self.assertEqual(collection_rights_change_object.new_status,
                         rights_domain.ACTIVITY_STATUS_PUBLIC)
Example #12
0
    def test_collection_rights_change_object_with_change_private_viewability(
            self):
        collection_rights_change_object = rights_domain.CollectionRightsChange({
            'cmd': 'change_private_viewability',
            'old_viewable_if_private': 'old_viewable_if_private',
            'new_viewable_if_private': 'new_viewable_if_private'
        })

        self.assertEqual(
            collection_rights_change_object.cmd, 'change_private_viewability')
        self.assertEqual(
            collection_rights_change_object.old_viewable_if_private,
            'old_viewable_if_private')
        self.assertEqual(
            collection_rights_change_object.new_viewable_if_private,
            'new_viewable_if_private')
Example #13
0
    def test_collection_rights_change_object_with_change_private_viewability(
            self) -> None:
        collection_rights_change_object = rights_domain.CollectionRightsChange(
            {  # 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(collection_rights_change_object.cmd,
                         'change_private_viewability')
        self.assertEqual(
            collection_rights_change_object.old_viewable_if_private,
            'old_viewable_if_private')
        self.assertEqual(
            collection_rights_change_object.new_viewable_if_private,
            'new_viewable_if_private')
Example #14
0
    def test_collection_rights_change_object_with_update_first_published_msec(
            self) -> None:
        collection_rights_change_object = rights_domain.CollectionRightsChange(
            {  # 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(collection_rights_change_object.cmd,
                         'update_first_published_msec')
        self.assertEqual(
            collection_rights_change_object.old_first_published_msec,
            'old_first_published_msec')
        self.assertEqual(
            collection_rights_change_object.new_first_published_msec,
            'new_first_published_msec')
 def test_collection_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.CollectionRightsChange({'cmd': 'invalid'})
Example #16
0
    def test_collection_rights_change_object_with_create_new(self):
        collection_rights_change_object = rights_domain.CollectionRightsChange(
            {'cmd': 'create_new'})

        self.assertEqual(collection_rights_change_object.cmd, 'create_new')
Example #17
0
 def test_collection_rights_change_object_with_invalid_cmd(self):
     with self.assertRaisesRegexp(utils.ValidationError,
                                  'Command invalid is not allowed'):
         rights_domain.CollectionRightsChange({'cmd': 'invalid'})
Example #18
0
 def test_collection_rights_change_object_with_missing_cmd(self):
     with self.assertRaisesRegexp(utils.ValidationError,
                                  'Missing cmd key in change dict'):
         rights_domain.CollectionRightsChange({'invalid': 'data'})
 def test_collection_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.CollectionRightsChange({'invalid': 'data'})