def test_truncating_querylogs(self): QueryLog(sql='foo').save() QueryLog.objects.filter(sql='foo').update(run_at=datetime.now() - timedelta(days=30)) QueryLog(sql='bar').save() QueryLog.objects.filter(sql='bar').update(run_at=datetime.now() - timedelta(days=29)) truncate_querylogs(30) self.assertEqual(QueryLog.objects.count(), 1)
def test_sql_changed_query(self): q = SimpleQueryFactory() ql = QueryLog(sql=q.sql, query_id=q.id) self.assertTrue(ql.should_save_sql()) ql.save() self.assertTrue(ql.should_save_sql()) ql2 = QueryLog(sql=q.sql, query_id=q.id) self.assertFalse(ql2.should_save_sql())
def test_is_playground(self): self.assertTrue(QueryLog(sql='foo').is_playground) q = SimpleQueryFactory() self.assertFalse(QueryLog(sql='foo', query_id=q.id).is_playground)