'Test to verify that aggregates are listed after function in metadata
test_aggregates_after_functions creates an aggregate, and then verifies that they are listed
after any function creations when the keypspace dump is preformed
@since 2.6.0
@jira_ticket PYTHON-211
@expected_result aggregates are declared after any functions
@test_category aggregate'

def test_aggregates_after_functions(self):

    with self.VerifiedAggregate(self, **self.make_aggregate_kwargs('extend_list', 'list<text>')):
        keyspace_cql = self.cluster.metadata.keyspaces[self.keyspace_name].export_as_string()
        func_idx = keyspace_cql.find('CREATE    FUNCTION')
        aggregate_idx = keyspace_cql.rfind('CREATE    AGGREGATE')
        self.assertNotIn((-1), (aggregate_idx, func_idx), ('AGGREGATE    or    FUNCTION    not    found    in    keyspace_cql:    ' + keyspace_cql))
        self.assertGreater(aggregate_idx, func_idx)
