MCPcopy
hub / github.com/celery/celery / test__close_database

Method test__close_database

t/unit/fixups/test_django.py:270–288  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

268 assert f._db_recycles == 1
269
270 def test__close_database(self):
271 with self.fixup_context(self.app) as (f, _, _):
272 conns = [Mock(), Mock(), Mock()]
273 conns[1].close.side_effect = KeyError('already closed')
274 f.DatabaseError = KeyError
275 f.interface_errors = ()
276
277 f._db.connections = Mock() # ConnectionHandler
278 f._db.connections.all.side_effect = lambda initialized_only: conns
279
280 f._close_database()
281 conns[0].close.assert_called_with()
282 conns[1].close.assert_called_with()
283 conns[2].close.assert_called_with()
284
285 conns[1].close.side_effect = KeyError(
286 'omg')
287 with pytest.raises(KeyError):
288 f._close_database()
289
290 def test__close_database_django_pre_41(self):
291 """Test that Django < 4.1 (without initialized_only parameter) is handled."""

Callers

nothing calls this directly

Calls 3

fixup_contextMethod · 0.80
_close_databaseMethod · 0.80
raisesMethod · 0.45

Tested by

no test coverage detected