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_volumedescdate_parse_zero():
drdate = pycdlib.dates.VolumeDescriptorDate()
drdate.parse(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
assert(drdate.year == 0)
assert(drdate.month == 0)
assert(drdate.dayofmonth == 0)
assert(drdate.hour == 0)
assert(drdate.minute == 0)
assert(drdate.second == 0)
assert(drdate.hundredthsofsecond == 0)
assert(drdate.gmtoffset == 0)
assert(drdate.date_str == b'0000000000000000' + b'\x00')
def test_volumedescdate_parse_nonzero():
drdate = pycdlib.dates.VolumeDescriptorDate()
drdate.parse(b'2019010721250000\x00')
assert(drdate.year == 2019)
assert(drdate.month == 1)
assert(drdate.dayofmonth == 7)
assert(drdate.hour == 21)
assert(drdate.minute == 25)
assert(drdate.second == 0)
assert(drdate.hundredthsofsecond == 0)
assert(drdate.gmtoffset == 0)
def test_volumedescdate_test_equal():
drdate = pycdlib.dates.VolumeDescriptorDate()
drdate.new(1546914300.0)
drdate2 = pycdlib.dates.VolumeDescriptorDate()
drdate2.new(1546914300.0)
assert(not(drdate != drdate2))
def test_volumedescdate_record_not_initialized():
voldate = pycdlib.dates.VolumeDescriptorDate()
with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
voldate.record()
assert(str(excinfo.value) == 'This Volume Descriptor Date is not initialized')
def test_volumedescdate_parse_after_new():
drdate = pycdlib.dates.VolumeDescriptorDate()
drdate.new()
with pytest.raises(pycdlib.pycdlibexception.PyCdlibInternalError) as excinfo:
drdate.parse(b'')
assert(str(excinfo.value) == 'This Volume Descriptor Date object is already initialized')
def test_volumedescdate_parse_invalid_string():
voldate = pycdlib.dates.VolumeDescriptorDate()
with pytest.raises(pycdlib.pycdlibexception.PyCdlibInvalidISO) as excinfo:
voldate.parse(b'')
assert(str(excinfo.value) == 'Invalid ISO9660 date string')
self.path_table_location_be = utils.swab_32bit(self.path_table_location_be)
self.publisher_identifier = FileOrTextIdentifier()
self.publisher_identifier.parse(pub_ident_str)
self.preparer_identifier = FileOrTextIdentifier()
self.preparer_identifier.parse(prepare_ident_str)
self.application_identifier = FileOrTextIdentifier()
self.application_identifier.parse(app_ident_str)
self.volume_creation_date = dates.VolumeDescriptorDate()
self.volume_creation_date.parse(vol_create_date_str)
self.volume_modification_date = dates.VolumeDescriptorDate()
self.volume_modification_date.parse(vol_mod_date_str)
self.volume_expiration_date = dates.VolumeDescriptorDate()
self.volume_expiration_date.parse(vol_expire_date_str)
self.volume_effective_date = dates.VolumeDescriptorDate()
self.volume_effective_date.parse(vol_effective_date_str)
self.root_dir_record.parse(self, root_dir_record, None)
self.orig_extent_loc = extent_loc
self._initialized = True
self.application_identifier.new(utils.encode_space_pad(app_ident_str, 128, encoding))
self.copyright_file_identifier = utils.encode_space_pad(copyright_file, 37, encoding)
self.abstract_file_identifier = utils.encode_space_pad(abstract_file, 37, encoding)
self.bibliographic_file_identifier = utils.encode_space_pad(bibli_file, 37, encoding)
now = time.time()
self.volume_creation_date = dates.VolumeDescriptorDate()
self.volume_creation_date.new(now)
# We make a valid volume modification date here, but it will get
# overwritten during record().
self.volume_modification_date = dates.VolumeDescriptorDate()
self.volume_modification_date.new(now)
self.volume_expiration_date = dates.VolumeDescriptorDate()
self.volume_expiration_date.new(vol_expire_date)
self.volume_effective_date = dates.VolumeDescriptorDate()
self.volume_effective_date.new(now)
if xa:
if len(app_use) > 141:
raise pycdlibexception.PyCdlibInvalidInput('Cannot have XA and an app_use of > 140 bytes')
self.application_use = app_use.ljust(141, b' ')
self.application_use += b'CD-XA001' + b'\x00' * 18
self.application_use = self.application_use.ljust(512, b' ')
else:
if len(app_use) > 512:
raise pycdlibexception.PyCdlibInvalidInput('The maximum length for the application use is 512')
self.application_use = app_use.ljust(512, b' ')
self._initialized = True
'''
if self._initialized:
raise pycdlibexception.PyCdlibInternalError('TF record already initialized')
self.time_flags = time_flags
tflen = 7
if self.time_flags & (1 << 7):
tflen = 17
for index, fieldname in enumerate(self.FIELDNAMES):
if self.time_flags & (1 << index):
if tflen == 7:
setattr(self, fieldname, dates.DirectoryRecordDate())
elif tflen == 17:
setattr(self, fieldname, dates.VolumeDescriptorDate())
getattr(self, fieldname).new()
self._initialized = True
self.publisher_identifier = FileOrTextIdentifier()
self.publisher_identifier.new(utils.encode_space_pad(pub_ident_str, 128, encoding))
self.preparer_identifier = FileOrTextIdentifier()
self.preparer_identifier.new(utils.encode_space_pad(preparer_ident_str, 128, encoding))
self.application_identifier = FileOrTextIdentifier()
self.application_identifier.new(utils.encode_space_pad(app_ident_str, 128, encoding))
self.copyright_file_identifier = utils.encode_space_pad(copyright_file, 37, encoding)
self.abstract_file_identifier = utils.encode_space_pad(abstract_file, 37, encoding)
self.bibliographic_file_identifier = utils.encode_space_pad(bibli_file, 37, encoding)
now = time.time()
self.volume_creation_date = dates.VolumeDescriptorDate()
self.volume_creation_date.new(now)
# We make a valid volume modification date here, but it will get
# overwritten during record().
self.volume_modification_date = dates.VolumeDescriptorDate()
self.volume_modification_date.new(now)
self.volume_expiration_date = dates.VolumeDescriptorDate()
self.volume_expiration_date.new(vol_expire_date)
self.volume_effective_date = dates.VolumeDescriptorDate()
self.volume_effective_date.new(now)
if xa:
if len(app_use) > 141:
raise pycdlibexception.PyCdlibInvalidInput('Cannot have XA and an app_use of > 140 bytes')
self.application_use = app_use.ljust(141, b' ')
self.application_use += b'CD-XA001' + b'\x00' * 18
self.application_use = self.application_use.ljust(512, b' ')