(self, table, columns, to, value=True, using="default")
| 156 | ) |
| 157 | |
| 158 | def assertFKExists(self, table, columns, to, value=True, using="default"): |
| 159 | if not connections[using].features.can_introspect_foreign_keys: |
| 160 | return |
| 161 | with connections[using].cursor() as cursor: |
| 162 | self.assertEqual( |
| 163 | value, |
| 164 | any( |
| 165 | c["foreign_key"] == to |
| 166 | for c in connections[using] |
| 167 | .introspection.get_constraints(cursor, table) |
| 168 | .values() |
| 169 | if c["columns"] == list(columns) |
| 170 | ), |
| 171 | ) |
| 172 | |
| 173 | def assertFKNotExists(self, table, columns, to): |
| 174 | return self.assertFKExists(table, columns, to, False) |
no test coverage detected