Add another cleanup test and fix celery test broker

Turns out celery doesn't like in-memory sql backends, but has a
built-in memory broker. Use that instead and remove sqlalchemy
requirement
This commit is contained in:
Frank Hamand 2017-02-16 12:56:20 +00:00
parent 9388274b84
commit 30df15d19a
3 changed files with 17 additions and 2 deletions

View File

@ -990,6 +990,22 @@ class TestCleanUpTask(LocalTestCase):
tasks.clean_db(batch_size=1) tasks.clean_db(batch_size=1)
self.assertEqual(StatusCheckResult.objects.all().count(), initial_results) self.assertEqual(StatusCheckResult.objects.all().count(), initial_results)
def test_cleanup_single_batch(self):
with self.settings(CELERY_ALWAYS_EAGER=False):
initial_results = StatusCheckResult.objects.all().count()
for i in range(2):
StatusCheckResult(
status_check=self.graphite_check,
time=timezone.now() - timedelta(days=61),
time_complete=timezone.now() - timedelta(days=61),
succeeded=False
).save()
self.assertEqual(StatusCheckResult.objects.all().count(), initial_results + 2)
tasks.clean_db(batch_size=1)
self.assertEqual(StatusCheckResult.objects.all().count(), initial_results + 1)
class TestMinimizeTargets(LocalTestCase): class TestMinimizeTargets(LocalTestCase):
def test_null(self): def test_null(self):

View File

@ -1,6 +1,6 @@
DATABASE_URL=sqlite://:memory: DATABASE_URL=sqlite://:memory:
CELERY_BROKER_URL=sqla+sqlite://:memory: CELERY_BROKER_URL=memory://
CELERY_RESULT_BACKEND=db+sqlite://:memory: CELERY_RESULT_BACKEND=db+sqlite://:memory:
CELERY_ALWAYS_EAGER=true CELERY_ALWAYS_EAGER=true

View File

@ -1,5 +1,4 @@
coverage==4.2 coverage==4.2
django_coverage_plugin==1.3.1 django_coverage_plugin==1.3.1
mock==1.0.1 mock==1.0.1
sqlalchemy==1.1.5
ipdb ipdb