Exemple #1
0
def test_get_multi_by_indices_with_date(faker, user, action):
    log = AuditLog.create(user.id, faker.ipv4(), action)
    today = datetime.date.today()
    yesterday = today + datetime.timedelta(days=-1)
    assert AuditLog.get_multi_by_index_with_date(
        AuditLog.TYPE_SITE, 0, today)[:] == [log]
    assert AuditLog.get_multi_by_index_with_date(
        AuditLog.TYPE_SITE, 0, yesterday)[:] == []
Exemple #2
0
 def _get_audit_logs(self, target_id, start, date):
     if target_id is None:
         return []
     if date:
         audit_logs = AuditLog.get_multi_by_index_with_date(
             self.target_type, target_id, date)
     else:
         audit_logs = AuditLog.get_multi_by_index(self.target_type,
                                                  target_id)
     return audit_logs[start:start + 100]