Пример #1
0
 def assert_no_creation(status=200):
     assert PluginChannel.selectBy(
         name=channel_params['name']).getOne(None) is None
     assert self.testApp.post('/channels',
                              params=channel_params,
                              status=status).body is not None
     assert PluginChannel.selectBy(
         name=channel_params['name']).getOne(None) is None
     assert ChannelBundle.selectBy(
         name=bundle_params['name']).getOne(None) is None
     assert self.testApp.post('/channels',
                              params=bundle_params,
                              status=status).body is not None
     assert ChannelBundle.selectBy(
         name=bundle_params['name']).getOne(None) is None
Пример #2
0
 def assert_no_deletion(channel_params=channel_params,
                        bundle_params=bundle_params,
                        status=200):
     assert self.testApp.post('/channels',
                              params=channel_params,
                              status=status).body is not None
     assert PluginChannel.selectBy(id=pc1_id).getOne(None) is not None
     assert self.testApp.post('/channels',
                              params=bundle_params,
                              status=status).body is not None
     assert ChannelBundle.selectBy(
         id=bundle_id).getOne(None) is not None
Пример #3
0
 def assert_deletion(channel_params=channel_params,
                     bundle_params=bundle_params,
                     status=200):
     assert self.testApp.post('/channels',
                              params=channel_params,
                              status=status).body is not None
     assert PluginChannel.selectBy(id=pc1_id).getOne(None) is None
     assert self.testApp.post('/channels',
                              params=bundle_params,
                              status=status).body is not None
     assert ChannelBundle.selectBy(id=bundle_id).getOne(None) is None
     return (PluginChannel(plugin=self.fake_plugin,
                           name='PC 1',
                           subscription_right='public').id,
             ChannelBundle(name='Bundle',
                           subscription_right='public').id)
Пример #4
0
    def runTest(self):
        """ Tests the channels deletion through the Channels page """
        pc1_id = self.pc1.id
        bundle_id = self.bundle.id

        channel_params = {'action': 'delete-channel', 'id': pc1_id}
        bundle_params = {'action': 'delete-bundle', 'id': bundle_id}

        def assert_deletion(channel_params=channel_params,
                            bundle_params=bundle_params,
                            status=200):
            assert self.testApp.post('/channels',
                                     params=channel_params,
                                     status=status).body is not None
            assert PluginChannel.selectBy(id=pc1_id).getOne(None) is None
            assert self.testApp.post('/channels',
                                     params=bundle_params,
                                     status=status).body is not None
            assert ChannelBundle.selectBy(id=bundle_id).getOne(None) is None
            return (PluginChannel(plugin=self.fake_plugin,
                                  name='PC 1',
                                  subscription_right='public').id,
                    ChannelBundle(name='Bundle',
                                  subscription_right='public').id)

        def assert_no_deletion(channel_params=channel_params,
                               bundle_params=bundle_params,
                               status=200):
            assert self.testApp.post('/channels',
                                     params=channel_params,
                                     status=status).body is not None
            assert PluginChannel.selectBy(id=pc1_id).getOne(None) is not None
            assert self.testApp.post('/channels',
                                     params=bundle_params,
                                     status=status).body is not None
            assert ChannelBundle.selectBy(
                id=bundle_id).getOne(None) is not None

        # Test basic functionality
        pc1_id, bundle_id = assert_deletion()
        channel_params['id'] = pc1_id
        bundle_params['id'] = bundle_id

        # Test insufficient permissions for channel edition
        for u in [
                self.user_nothing, self.user_contrib, self.user_chan_admin,
                self.user_screen_admin, self.user_admin
        ]:
            self.ictv_app.test_user = {'email': u.email}
            assert_no_deletion(status=403)

        # Test sufficient permissions for channel edition
        for u in [self.user_super_admin]:
            self.ictv_app.test_user = {'email': u.email}
            pc1_id, bundle_id = assert_deletion()
            channel_params['id'] = pc1_id
            bundle_params['id'] = bundle_id

            # Test invalid id
            channel_params['id'] = bundle_params['id'] = -1
            assert_no_deletion()
            channel_params['id'] = bundle_params['id'] = 'invalid'
            assert_no_deletion()
            channel_params['id'] = pc1_id
            bundle_params['id'] = bundle_id

        # Test subscriptions
        pc1_id, bundle_id = assert_deletion()
        channel_params['id'] = pc1_id
        bundle_params['id'] = bundle_id
        self.pc1 = PluginChannel.get(pc1_id)
        self.bundle = ChannelBundle.get(bundle_id)
        self.screen.subscribe_to(self.user_super_admin, self.pc1)
        assert self.testApp.post('/channels',
                                 params=channel_params,
                                 status=200).body is not None
        assert PluginChannel.selectBy(id=pc1_id).getOne(None) is not None
        self.screen.subscribe_to(self.user_super_admin, self.bundle)
        assert self.testApp.post('/channels', params=bundle_params,
                                 status=200).body is not None
        assert ChannelBundle.selectBy(id=bundle_id).getOne(None) is not None
        self.screen.unsubscribe_from(self.user_super_admin, self.pc1)
        assert self.testApp.post('/channels',
                                 params=channel_params,
                                 status=200).body is not None
        assert PluginChannel.selectBy(id=pc1_id).getOne(None) is None
        self.screen.unsubscribe_from(self.user_super_admin, self.bundle)
        assert self.testApp.post('/channels', params=bundle_params,
                                 status=200).body is not None
        assert ChannelBundle.selectBy(id=bundle_id).getOne(None) is None