Compare the results of a raw query against expected results
(self, model, results, orig, expected_annotations=())
| 88 | self.assertAnnotations(results, expected_annotations) |
| 89 | |
| 90 | def assertProcessed(self, model, results, orig, expected_annotations=()): |
| 91 | """ |
| 92 | Compare the results of a raw query against expected results |
| 93 | """ |
| 94 | self.assertEqual(len(results), len(orig)) |
| 95 | for index, item in enumerate(results): |
| 96 | orig_item = orig[index] |
| 97 | for annotation in expected_annotations: |
| 98 | setattr(orig_item, *annotation) |
| 99 | |
| 100 | for field in model._meta.fields: |
| 101 | # All values on the model are equal |
| 102 | self.assertEqual( |
| 103 | getattr(item, field.attname), getattr(orig_item, field.attname) |
| 104 | ) |
| 105 | # This includes checking that they are the same type |
| 106 | self.assertEqual( |
| 107 | type(getattr(item, field.attname)), |
| 108 | type(getattr(orig_item, field.attname)), |
| 109 | ) |
| 110 | |
| 111 | def assertNoAnnotations(self, results): |
| 112 | """ |
no outgoing calls
no test coverage detected