File: test_ptr.py

package info (click to toggle)
python-pycdlib 1.12.0%2Bds1-4%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,044 kB
  • sloc: python: 35,639; makefile: 63
file content (79 lines) | stat: -rw-r--r-- 2,962 bytes parent folder | download | duplicates (2)
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
from __future__ import absolute_import

import pytest
import os
import sys
try:
    from cStringIO import StringIO as BytesIO
except ImportError:
    from io import BytesIO
import struct

prefix = '.'
for i in range(0, 3):
    if os.path.isdir(os.path.join(prefix, 'pycdlib')):
        sys.path.insert(0, prefix)
        break
    else:
        prefix = '../' + prefix

import pycdlib.path_table_record

def test_path_table_record_parse_initialized_twice():
    ptr = pycdlib.path_table_record.PathTableRecord()
    ptr.parse(b'\x00\x00\x00\x00\x00\x00\x00\x00')

    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        ptr.parse(b'\x00\x00\x00\x00\x00\x00\x00\x00')
    assert(str(excinfo.value) == 'Path Table Record already initialized')

def test_path_table_record_record_little_endian_not_initialized():
    ptr = pycdlib.path_table_record.PathTableRecord()

    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        ptr.record_little_endian()
    assert(str(excinfo.value) == 'Path Table Record not initialized')

def test_path_table_record_record_big_endian_not_initialized():
    ptr = pycdlib.path_table_record.PathTableRecord()

    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        ptr.record_big_endian()
    assert(str(excinfo.value) == 'Path Table Record not initialized')

def test_path_table_record_new_root_initialized_twice():
    ptr = pycdlib.path_table_record.PathTableRecord()
    ptr.new_root()

    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        ptr.new_root()
    assert(str(excinfo.value) == 'Path Table Record already initialized')

def test_path_table_record_new_dir_initialized_twice():
    ptr = pycdlib.path_table_record.PathTableRecord()
    ptr.new_dir(b'foo')

    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        ptr.new_dir(b'foo')
    assert(str(excinfo.value) == 'Path Table Record already initialized')

def test_path_table_record_update_extent_location_not_initialized():
    ptr = pycdlib.path_table_record.PathTableRecord()

    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        ptr.update_extent_location(0)
    assert(str(excinfo.value) == 'Path Table Record not initialized')

def test_path_table_record_update_parent_directory_number_not_initialized():
    ptr = pycdlib.path_table_record.PathTableRecord()

    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        ptr.update_parent_directory_number(0)
    assert(str(excinfo.value) == 'Path Table Record not initialized')

def test_path_table_record_equal_to_be_not_initialized():
    ptr = pycdlib.path_table_record.PathTableRecord()

    with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
        ptr.equal_to_be(None)
    assert(str(excinfo.value) == 'Path Table Record not initialized')