The Django testing framework should provide assertNumQueries(), which would assert that a given action executed a given number of database queries. This should work at the view level ("view X uses 3 queries total") or the individual statement level ("model method X uses only 1 query").
This might have to be implemented as two methods -- a "start counting" method and a "stop counting" method:
def test_something(self):
self.startCountingQueries()
do_something_that_should_only_use_two_queries()
self.assertNumQueries(2)
In this example, startCountingQueries() would reset the counter to 0, and every query would be tallied from that point on. assertNumQueries() would simply assert the query count was the given number.
Note that this depends on #5415, which provides signals for every SQL query.