def test_uu_bad_headers(self): """ Make sure we fail on bad headers """ # Initialize Codec ud = CodecUU(work_dir=self.tmp_dir, out_dir=self.out_dir) # Make sure we don't pick up on yenc content assert ud.detect( "=ybegin line=1024 size=12345", ) is None yenc_meta = ud.detect( "begin BDP FILENAME", ) # The BDP (Bad Permission) assumes to be part of the filename assert len(yenc_meta) == 2 assert yenc_meta['key'] == 'begin' assert yenc_meta['name'] == 'BDP FILENAME'
def test_uu_headers(self): """ Test that we can pick up the uu headers correctly """ # Initialize Codec ud = CodecUU(work_dir=self.tmp_dir, out_dir=self.out_dir) uu_meta = ud.detect("begin 775 mybinary.dat") assert uu_meta is not None assert len(uu_meta) == 3 assert uu_meta['key'] == 'begin' assert uu_meta['perm'] == 0775 assert uu_meta['name'] == 'mybinary.dat' # Whitespace has no bearing uu_meta = ud.detect(" begin 775 mybinary.dat ") assert uu_meta is not None assert len(uu_meta) == 3 assert uu_meta['key'] == 'begin' assert uu_meta['perm'] == 0775 assert uu_meta['name'] == 'mybinary.dat' # End fails because we're processing content relative # to the decoder (which is expecing a begin at this time) uu_meta = ud.detect(" end ") assert uu_meta is None # end also doesn't care about whitespace uu_meta = ud.detect(" end ", relative=False) assert uu_meta is not None assert len(uu_meta) == 1 assert uu_meta['key'] == 'end' # The '`' tilda character is used on the line # prior to the 'end' keyword. we ignore this # entry in most cases, but treat it as a key # none the less. uu_meta = ud.detect("`", relative=False) assert uu_meta is not None assert len(uu_meta) == 1 assert uu_meta['key'] == '`'