Cache lookups of LocalSites in the API unit tests.

We fetch LocalSites quite a lot in the API unit tests. This attempts to
reduce the number of queries by caching and returning them after they've
already been queried once.

Reviewed at https://reviews.reviewboard.org/r/6084/