'Testing whether a channel is correctly modified'

@blocking_call_on_reactor_thread
@inlineCallbacks
def test_edit_channel(self):

    self.create_my_channel('test', 'test')
    mock_channel_community = MockObject()
    mock_channel_community.called_modify = False
    def verify_channel_modified(_):
        self.assertTrue(mock_channel_community.called_modify)
    def modify_channel_called(modifications):
        self.assertEqual(modifications['name'], 'test1')
        self.assertEqual(modifications['description'], 'test2')
        mock_channel_community.called_modify = True
    mock_channel_community.modifyChannel = modify_channel_called
    mock_dispersy = MockObject()
    mock_dispersy.get_community = (lambda _: mock_channel_community)
    self.session.get_dispersy_instance = (lambda : mock_dispersy)
    self.should_check_equality = False
    post_params = {'name': '', 'description': 'test2'}
    (yield self.do_request('mychannel', expected_code=400, post_data=post_params, request_type='POST'))
    self.should_check_equality = True
    post_params = {'name': 'test1', 'description': 'test2'}
    (yield self.do_request('mychannel', expected_code=200, expected_json={'modified': True}, post_data=post_params, request_type='POST').addCallback(verify_channel_modified))
