On Sunday, August 17, 2014 8:39:17 PM UTC+6, James Bennett wrote:
>
> Not sure about the feasibility, though; would you be willing to work up a 
> rough implementation of it?
>

Implementation of the assertion is straightforward, because it can be a 
direct copy of AssertNumQueries with:

self.test_case.assertLessEqual(

          executed, self.num, "%d queries executed, %d or less expected" % (

              executed, self.num

          )

instead of the the assertEqual in AssertNumQueries.

Regarding it's use, I run it with a low default and then make exceptions 
for specific urls that I know have more queries:

        max_queries = {'admin:app1_model1_change': 50,

                     'admin:app1_model2_add': 100,

                     'admin:app2_model1_changelist': 100}

<snip>

        for model in get_models():

          if model in admin.site._registry:

              try:

                 if admin.site._registry[model].has_add_permission(type(
"request", (), {"user": user})):

                        route = "admin:%s_%s_add" % (model._meta.app_label, 
model._meta.module_name)

                      url = reverse(route)

                      with self.assertMaxQueries(max_queries.get(route, 10
)):

                          response = self.client.get(url, follow=True)

I'm happy to create a GitHub pull request for the Assertion and the 
required documentation changes
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/3d490eaa-d6a5-4025-b46b-28f14dddfcaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to