File: dependencies.py

package info (click to toggle)
dfvfs 20160918-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 96,408 kB
  • ctags: 2,759
  • sloc: python: 22,682; makefile: 57; vhdl: 25; sh: 16
file content (103 lines) | stat: -rwxr-xr-x 3,279 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Tests for the dependencies helper functions."""

import socket
import unittest

from dfvfs import dependencies


try:
  hostname = socket.gethostbyname(u'github.com')
except socket.error:
  hostname = None


class DependenciesTest(unittest.TestCase):
  """A unit test for the dependencies helper functions."""

  # pylint: disable=protected-access

  # Show full diff results, part of TestCase so does not follow our naming
  # conventions.
  maxDiff = None

  def testCheckLibyal(self):
    """Tests the _CheckLibyal function."""
    result = dependencies._CheckLibyal(
        {u'pybde': 20140531}, verbose_output=False)
    self.assertTrue(result)

    result = dependencies._CheckLibyal({u'bogus': 0}, verbose_output=False)
    self.assertFalse(result)

  @unittest.skipUnless(hostname, 'no internet connectivity')
  def testCheckLibyalWithLatestVersionCheck(self):
    """Tests the _CheckLibyal function with latest version check."""
    result = dependencies._CheckLibyal(
        {u'pybde': 20140531}, latest_version_check=True,
        verbose_output=False)
    self.assertTrue(result)

  def testCheckPythonModule(self):
    """Tests the _CheckPythonModule function."""
    result = dependencies._CheckPythonModule(
        u'dfdatetime', u'__version__', u'20160311', verbose_output=False)
    self.assertTrue(result)

    result = dependencies._CheckPythonModule(
        u'bogus', u'__version__', u'0', verbose_output=False)
    self.assertFalse(result)

  def testCheckPyTSK(self):
    """Tests the _CheckPyTSK function."""
    result = dependencies._CheckPyTSK(verbose_output=False)
    self.assertTrue(result)

  def testCheckSQLite3(self):
    """Tests the _CheckSQLite3 function."""
    result = dependencies._CheckSQLite3(verbose_output=False)
    self.assertTrue(result)

  def testImportPythonModule(self):
    """Tests the _ImportPythonModule function."""
    module = dependencies._ImportPythonModule(u'os')
    self.assertIsNotNone(module)

    module = dependencies._ImportPythonModule(u'bogus')
    self.assertIsNone(module)

  def testCheckDependencies(self):
    """Tests the CheckDependencies function."""
    result = dependencies.CheckDependencies(verbose_output=False)
    self.assertTrue(result)

  def testCheckModuleVersion(self):
    """Tests the CheckModuleVersion function."""
    dependencies.CheckModuleVersion(u'dfdatetime')

    with self.assertRaises(ImportError):
      dependencies.CheckModuleVersion(u'bogus')

  def testGetDPKGDepends(self):
    """Tests the GetDPKGDepends function."""
    install_requires = dependencies.GetDPKGDepends()
    self.assertIn(u'libbde-python (>= 20140531)', install_requires)

    install_requires = dependencies.GetDPKGDepends(exclude_version=True)
    self.assertIn(u'libbde-python', install_requires)

  def testGetInstallRequires(self):
    """Tests the GetInstallRequires function."""
    install_requires = dependencies.GetInstallRequires()
    self.assertIn(u'libbde-python >= 20140531', install_requires)

  def testGetRPMRequires(self):
    """Tests the GetRPMRequires function."""
    install_requires = dependencies.GetRPMRequires()
    self.assertIn(u'libbde-python >= 20140531', install_requires)


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