Use subscripting for looking up targets in resources_by_products

And add a test for a regression that RB 1250 caused when multiple partitions
were combined with resources_by_targets.

Testing Done:
Ran tests

Reviewed at https://rbcommons.com/s/twitter/r/1380/
Sync of https://github.com/pantsbuild/pants/commit/1b7950610687f9d52e799f55856f5a01a517c408