'There should not be O(N) queries.'

def test_list_users_call_count(self):

    for i in range(10):
        user = unit.new_user_ref(domain_id=CONF.identity.default_domain_id)
        self.identity_api.create_user(user)
    class CallCounter(object, ):
        def __init__(self):
            self.calls = 0
        def reset(self):
            self.calls = 0
        def query_counter(self, query):
            self.calls += 1
    counter = CallCounter()
    sqlalchemy.event.listen(sqlalchemy.orm.query.Query, 'before_compile', counter.query_counter)
    first_call_users = self.identity_api.list_users()
    first_call_counter = counter.calls
    for i in range(10):
        user = unit.new_user_ref(domain_id=CONF.identity.default_domain_id)
        self.identity_api.create_user(user)
    counter.reset()
    second_call_users = self.identity_api.list_users()
    self.assertNotEqual(len(first_call_users), len(second_call_users))
    self.assertEqual(first_call_counter, counter.calls)
