File: factory.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 (44 lines) | stat: -rw-r--r-- 1,346 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
38
39
40
41
42
43
44
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for the storage factory."""

from __future__ import unicode_literals

import unittest

from plaso.containers import sessions
from plaso.storage import factory
from plaso.storage.sqlite import reader as sqlite_reader
from plaso.storage.sqlite import writer as sqlite_writer

from tests.storage import test_lib


class StorageFactoryTest(test_lib.StorageTestCase):
  """Tests for the storage factory."""

  def testCreateStorageReaderForFile(self):
    """Test the CreateStorageReaderForFile function."""
    test_file_path = self._GetTestFilePath(['psort_test.plaso'])
    self._SkipIfPathNotExists(test_file_path)

    storage_reader = factory.StorageFactory.CreateStorageReaderForFile(
        test_file_path)
    self.assertIsInstance(
        storage_reader, sqlite_reader.SQLiteStorageFileReader)

  def testCreateStorageWriterForFile(self):
    """Test the CreateStorageWriterForFile function."""
    session = sessions.Session()

    test_file_path = self._GetTestFilePath(['psort_test.plaso'])
    self._SkipIfPathNotExists(test_file_path)

    storage_reader = factory.StorageFactory.CreateStorageWriterForFile(
        session, test_file_path)
    self.assertIsInstance(
        storage_reader, sqlite_writer.SQLiteStorageFileWriter)


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