'Test to verify that the initial_cond and final_func parameters are correctly honored
test_cql_optional_params creates various aggregates with different combinations of initial_condition,
and final_func parameters set. It then ensures they are correctly honored.
@since 2.6.0
@jira_ticket PYTHON-211
@expected_result initial_condition and final_func parameters are honored correctly
@test_category function'

def test_cql_optional_params(self):

    kwargs = self.make_aggregate_kwargs('extend_list', 'list<text>')
    encoder = Encoder()
    self.assertIsNone(kwargs['initial_condition'])
    self.assertIsNone(kwargs['final_func'])
    with self.VerifiedAggregate(self, **kwargs) as va:
        meta = self.keyspace_aggregate_meta[va.signature]
        self.assertIsNone(meta.initial_condition)
        self.assertIsNone(meta.final_func)
        cql = meta.as_cql_query()
        self.assertEqual(cql.find('INITCOND'), (-1))
        self.assertEqual(cql.find('FINALFUNC'), (-1))
    kwargs['initial_condition'] = encoder.cql_encode_all_types(['init', 'cond'])
    with self.VerifiedAggregate(self, **kwargs) as va:
        meta = self.keyspace_aggregate_meta[va.signature]
        self.assertEqual(meta.initial_condition, kwargs['initial_condition'])
        self.assertIsNone(meta.final_func)
        cql = meta.as_cql_query()
        search_string = ('INITCOND    %s' % kwargs['initial_condition'])
        self.assertGreater(cql.find(search_string), 0, ('"%s"    search    string    not    found    in    cql:\n%s' % (search_string, cql)))
        self.assertEqual(cql.find('FINALFUNC'), (-1))
    kwargs['initial_condition'] = None
    kwargs['final_func'] = 'List_As_String'
    with self.VerifiedAggregate(self, **kwargs) as va:
        meta = self.keyspace_aggregate_meta[va.signature]
        self.assertIsNone(meta.initial_condition)
        self.assertEqual(meta.final_func, kwargs['final_func'])
        cql = meta.as_cql_query()
        self.assertEqual(cql.find('INITCOND'), (-1))
        search_string = ('FINALFUNC    "%s"' % kwargs['final_func'])
        self.assertGreater(cql.find(search_string), 0, ('"%s"    search    string    not    found    in    cql:\n%s' % (search_string, cql)))
    kwargs['initial_condition'] = encoder.cql_encode_all_types(['init', 'cond'])
    kwargs['final_func'] = 'List_As_String'
    with self.VerifiedAggregate(self, **kwargs) as va:
        meta = self.keyspace_aggregate_meta[va.signature]
        self.assertEqual(meta.initial_condition, kwargs['initial_condition'])
        self.assertEqual(meta.final_func, kwargs['final_func'])
        cql = meta.as_cql_query()
        init_cond_idx = cql.find(('INITCOND    %s' % kwargs['initial_condition']))
        final_func_idx = cql.find(('FINALFUNC    "%s"' % kwargs['final_func']))
        self.assertNotIn((-1), (init_cond_idx, final_func_idx))
        self.assertGreater(init_cond_idx, final_func_idx)
