You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
======================================================================
| FAIL: test_db_error_w_atomic_requests (tests.test_views.TestDBError)
| ----------------------------------------------------------------------
| Traceback (most recent call last):
| File "/opt/hostedtoolcache/Python/3.9.9/x64/lib/python3.9/site-packages/django/test/utils.py", line 437, in inner
| return func(*args, **kwargs)
| File "/opt/hostedtoolcache/Python/3.9.9/x64/lib/python3.9/unittest/mock.py", line 1336, in patched
| return func(*newargs, **newkeywargs)
| File "/Users/michael/wave/src/sandbox/django-watchman/tests/test_views.py", line 319, in test_db_error_w_atomic_requests
| self.assertEqual(response.status_code, 201)
| AssertionError: 200 != 201
Full test class that will be removed for now:
classTestDBError(TransactionTestCase):
""" Ensure that we produce a valid response even in case of database connection issues with `ATOMIC_REQUESTS` enabled. Since overriding `DATABASES` isn't officially supported we need to perform some gymnastics here to convince django. """defsetUp(self):
# Cache current database connectionsself.databases=copy(connections._databases)
self.connection=getattr(connections._connections, DEFAULT_DB_ALIAS, None)
delconnections.__dict__['databases'] # remove cached_property valueconnections._databases=Noneconnections._connections=local()
deftearDown(self):
# Restore previous database connectionsconnections._databases=self.databasessetattr(connections._connections, DEFAULT_DB_ALIAS, self.connection)
delconnections.__dict__['databases'] # remove cached_property value@override_settings(DATABASES={'default': {"ENGINE": "django.db.backends.mysql","HOST": "no.host.by.this.name.some-tld-that-doesnt-exist","ATOMIC_REQUESTS": True }, } )# can't use override_settings because of# https://github.com/mwarkentin/django-watchman/issues/13@patch('watchman.settings.WATCHMAN_ERROR_CODE', 201)deftest_db_error_w_atomic_requests(self):
# Ensure we don't trigger django's generic 500 page in case of DB errorresponse=Client().get('/', data={
'check': 'watchman.checks.databases',
})
self.assertEqual(response.status_code, 201)
The text was updated successfully, but these errors were encountered:
@mwarkentin At the moment I'm not using django at all :/
I'll see if I have some time after Christmas to try remember what my thinking was there, but I can't promise anything ;)
There was some hacky code put in place for this test:
django-watchman/tests/test_views.py
Lines 281 to 320 in 67e4707
Full test class that will be removed for now:
The text was updated successfully, but these errors were encountered: