File: factory.py

package info (click to toggle)
dfvfs 20240505-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 475,508 kB
  • sloc: python: 36,533; vhdl: 1,922; sh: 448; xml: 52; makefile: 16
file content (52 lines) | stat: -rw-r--r-- 1,474 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
45
46
47
48
49
50
51
52
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for the volume system factory."""

import unittest

from dfvfs.lib import definitions
from dfvfs.volume import factory
from dfvfs.volume import volume_system


class TestVolumeSystem(volume_system.VolumeSystem):
  """Test volume system."""

  TYPE_INDICATOR = 'TEST'

  def _Parse(self):
    """Extracts sections and volumes from the volume system."""
    return


class FactoryTest(unittest.TestCase):
  """Class to test the volume system factory object."""

  def testVolumeSystemRegistration(self):
    """Tests the RegisterVolumeSystem and DeregisterVolumeSystem functions."""
    # pylint: disable=protected-access
    number_of_volume_system_types = len(factory.Factory._volume_system_types)

    factory.Factory.RegisterVolumeSystem(TestVolumeSystem)
    self.assertEqual(
        len(factory.Factory._volume_system_types),
        number_of_volume_system_types + 1)

    with self.assertRaises(KeyError):
      factory.Factory.RegisterVolumeSystem(TestVolumeSystem)

    factory.Factory.DeregisterVolumeSystem(TestVolumeSystem)
    self.assertEqual(
        len(factory.Factory._volume_system_types),
        number_of_volume_system_types)

  def testNewVolumeSystem(self):
    """Tests the NewVolumeSystem function."""
    test_volume_system = factory.Factory.NewVolumeSystem(
        definitions.TYPE_INDICATOR_GPT)

    self.assertIsNotNone(test_volume_system)


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