File: time_slices.py

package info (click to toggle)
plaso 20201007-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 519,924 kB
  • sloc: python: 79,002; sh: 629; xml: 72; sql: 14; vhdl: 11; makefile: 10
file content (37 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for the time slice."""

from __future__ import unicode_literals

import unittest

from plaso.cli import time_slices

from tests import test_lib as shared_test_lib


class TimeSliceTest(shared_test_lib.BaseTestCase):
  """Tests for the time slice."""

  def testInitialization(self):
    """Tests the __init__ function."""
    event_timestamp = 1467835655123456
    time_slice = time_slices.TimeSlice(event_timestamp)

    self.assertEqual(time_slice.event_timestamp, event_timestamp)
    self.assertEqual(time_slice.duration, 5)
    self.assertEqual(time_slice.end_timestamp, 1467835955123456)
    self.assertEqual(time_slice.start_timestamp, 1467835355123456)

    calculated_duration, _ = divmod(
        time_slice.end_timestamp - event_timestamp, 60 * 1000000)
    self.assertEqual(calculated_duration, 5)

    calculated_duration, _ = divmod(
        event_timestamp - time_slice.start_timestamp, 60 * 1000000)
    self.assertEqual(calculated_duration, 5)


if __name__ == '__main__':
  unittest.main()