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
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for the plist library functions."""
from __future__ import unicode_literals
import unittest
from plaso.lib import plist
from tests import test_lib as shared_test_lib
class PlistTests(shared_test_lib.BaseTestCase):
"""Class to test the plist file."""
def testGetValueByPath(self):
"""Tests the GetValueByPath function."""
test_file_path = self._GetTestFilePath(['com.apple.HIToolbox.plist'])
self._SkipIfPathNotExists(test_file_path)
with open(test_file_path, 'rb') as file_object:
plist_file = plist.PlistFile()
plist_file.Read(file_object)
path_segments = [
'AppleEnabledInputSources', '0', 'KeyboardLayout Name']
plist_value = plist_file.GetValueByPath(path_segments)
self.assertEqual(plist_value, 'U.S.')
def testReadBinary(self):
"""Tests the Read function on a binary plist file."""
test_file_path = self._GetTestFilePath(['com.apple.HIToolbox.plist'])
self._SkipIfPathNotExists(test_file_path)
with open(test_file_path, 'rb') as file_object:
plist_file = plist.PlistFile()
plist_file.Read(file_object)
self.assertIsNotNone(plist_file.root_key)
def testReadXML(self):
"""Tests the Read function on a XML plist file."""
test_file_path = self._GetTestFilePath(['com.apple.iPod.plist'])
self._SkipIfPathNotExists(test_file_path)
with open(test_file_path, 'rb') as file_object:
plist_file = plist.PlistFile()
plist_file.Read(file_object)
self.assertIsNotNone(plist_file.root_key)
if __name__ == '__main__':
unittest.main()
|