Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_timestamp_parse_initialized_twice():
ts = pycdlib.udf.UDFTimestamp()
ts.parse(b'\x00\x00\x01\x00\x01\x01\x00\x00\x00\x00\x00\x00')
with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
ts.parse(b'\x00\x00\x01\x00\x01\x01\x00\x00\x00\x00\x00\x00')
assert(str(excinfo.value) == 'UDF Timestamp already initialized')
def test_timestamp_parse_bad_month():
ts = pycdlib.udf.UDFTimestamp()
with pytest.raises(pycdlib.pycdlibexception.PyCdlibInvalidISO) as excinfo:
ts.parse(b'\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00')
assert(str(excinfo.value) == 'Invalid UDF month')
def test_timestamp_parse_bad_day():
ts = pycdlib.udf.UDFTimestamp()
with pytest.raises(pycdlib.pycdlibexception.PyCdlibInvalidISO) as excinfo:
ts.parse(b'\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00')
assert(str(excinfo.value) == 'Invalid UDF day')
def test_timestamp_new_initialized_twice():
ts = pycdlib.udf.UDFTimestamp()
ts.new()
with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
ts.new()
assert(str(excinfo.value) == 'UDF Timestamp already initialized')
def test_timestamp_equal():
ts = pycdlib.udf.UDFTimestamp()
ts.new()
ts2 = pycdlib.udf.UDFTimestamp()
ts2.new()
assert(ts == ts2)
def test_timestamp_record_not_initialized():
ts = pycdlib.udf.UDFTimestamp()
with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
ts.record()
assert(str(excinfo.value) == 'UDF Timestamp not initialized')
def test_timestamp_parse_bad_minute():
ts = pycdlib.udf.UDFTimestamp()
with pytest.raises(pycdlib.pycdlibexception.PyCdlibInvalidISO) as excinfo:
ts.parse(b'\x00\x00\x01\x00\x01\x01\x00\x40\x00\x00\x00\x00')
assert(str(excinfo.value) == 'Invalid UDF minute')
# split it into smaller. cdrkit/cdrtools uses 0x3ffff800, and
# Windows uses 0x3ff00000. To be more compatible with cdrkit,
# we'll choose their number of 0x3ffff800.
alloc_len = min(len_left, 0x3ffff800)
# The second field (position) is bogus, but will get set
# properly once reshuffle_extents is called.
self.alloc_descs.append([alloc_len, 0])
len_left -= alloc_len
self.access_time = UDFTimestamp()
self.access_time.new()
self.mod_time = UDFTimestamp()
self.mod_time.new()
self.attr_time = UDFTimestamp()
self.attr_time.new()
self.extended_attr_icb = UDFLongAD()
self.extended_attr_icb.new(0, 0)
self.impl_ident = UDFEntityID()
self.impl_ident.new(0, b'*pycdlib')
self.unique_id = 0 # this will get set later
self.len_extended_attrs = 0 # FIXME: let the user set this
self.extended_attrs = b''
self.parent = parent
self._initialized = True
# type: () -> None
'''
A method to create a new UDF File Set Descriptor.
Parameters:
None.
Returns:
Nothing.
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Set Descriptor already initialized')
self.desc_tag = UDFTag()
self.desc_tag.new(256) # FIXME: we should let the user set serial_number
self.recording_date = UDFTimestamp()
self.recording_date.new()
self.domain_ident = UDFEntityID()
self.domain_ident.new(0, b'*OSTA UDF Compliant', b'\x02\x01\x03')
self.root_dir_icb = UDFLongAD()
self.root_dir_icb.new(2048, 2)
self.file_set_num = 0
self.log_vol_char_set = _unicodecharset()
self.log_vol_ident = _ostaunicode_zero_pad('CDROM', 128)
self.file_set_char_set = _unicodecharset()
self.file_set_ident = _ostaunicode_zero_pad('CDROM', 32)
self.copyright_file_ident = b'\x00' * 32 # FIXME: let the user set this
self.abstract_file_ident = b'\x00' * 32 # FIXME: let the user set this