Ejemplo n.º 1
0
 def test_encoding_error(self):
     """Should not crash parsing garbage or non-ASCII SFV file"""
     sfv = io.BytesIO(b"; \x80 garbage comment\n"
                      b"\xFF garbage name 12345678\n"
                      b"garbage CRC \xA02345678\n"
                      b"--- \x9F garbage error line ---\n")
     parse_sfv_file(sfv)
Ejemplo n.º 2
0
    def test_sfv_diff(self):
        txtdir = os.path.join(os.pardir, os.pardir, "test_files", "txt")
        one = os.path.join(txtdir, "checksum.sfv")  # Unicode content
        two = os.path.join(txtdir, "checksum_copy.sfv")

        self.assertTrue(same_sfv(one, two), "SFV files not the same.")
        one, _, _ = parse_sfv_file(os.path.join(txtdir, "checksum.sfv"))
        two, _, _ = parse_sfv_file(os.path.join(txtdir, "checksum_copy.sfv"))
        one.append(SfvEntry("name"))
        self.assertFalse(one == two)
Ejemplo n.º 3
0
 def test_parse_sfv_file(self):
     sfv = os.path.join(os.pardir, os.pardir, "test_files",
                        "store_split_folder_old_srrsfv_windows",
                        "store_split_folder.sfv")
     (entries, comments, _errors) = parse_sfv_file(sfv)
     self.assertTrue(len(entries) == 3)
     self.assertTrue(len(comments) == 9)
Ejemplo n.º 4
0
    def test_parse_sfv(self):
        output = io.BytesIO()
        output.write(b"  ; sfv raped by teh skilled thugs\n"
                     b"test.r00 aabb0099  \n"
                     b"test.r01	  AABBCCDD\n"
                     b"test.rar	AABBCCDD\n"  # \t only
                     b"test.rar\tAABBDD\n"
                     b"test name with spaces.rar AABBCCDD\n"
                     b"test name with more spaces.rar	   AABBCCDD\n"
                     b"test name with ;.rar AABBCCDD\n"
                     b"  \n"
                     b"----------------------------------\n")
        output.write(b"illegal.rar AABBCCDD ; comment\n")

        (entries, comments, errors) = parse_sfv_file(output)
        self.assertTrue(len(entries) == 7)
        self.assertTrue(len(comments) == 1)
        self.assertTrue(len(errors) == 2)

        self.assertEqual(str(entries[0]), 'test.r00 aabb0099')

        # just supply the data
        output.seek(0)
        (entries, comments, errors) = parse_sfv_data(output.read())
        self.assertTrue(len(entries) == 7)
        self.assertTrue(len(comments) == 1)
        self.assertTrue(len(errors) == 2)
Ejemplo n.º 5
0
    def test_extra_spaces_and_tab(self):
        output = io.BytesIO()
        output.write(b"atest.rar	  AABBCCDD\n")

        (entries, comments, errors) = parse_sfv_file(output)
        self.assertTrue(len(entries) == 1)
        self.assertTrue(len(comments) == 0)
        self.assertTrue(len(errors) == 0)

        line = entries[0]
        self.assertEqual("atest.rar", line.file_name)
        self.assertEqual("AABBCCDD", line.crc32)
Ejemplo n.º 6
0
    def test_umlaut(self):
        output = io.BytesIO(b"; irgendwann_kommt_alles_zur\xfcck\n"
                            b"kommt_alles_zur\xfcck-tpmf.mp3 4EE8195C\n"
                            b"kommt_alles_zur\xfcck-tpmf.mp34EE8195C")
        (entries, comments, errors) = parse_sfv_file(output)

        self.assertTrue(len(entries) == 1)
        self.assertEqual("kommt_alles_zurück-tpmf.mp3", entries[0].file_name)
        self.assertEqual("4EE8195C", entries[0].crc32)

        self.assertTrue(len(comments) == 1)
        self.assertEqual("; irgendwann_kommt_alles_zurück", comments[0])

        self.assertTrue(len(errors) == 1)
        self.assertEqual("kommt_alles_zurück-tpmf.mp34EE8195C", errors[0])
Ejemplo n.º 7
0
 def test_sfv_quotes(self):
     output = io.BytesIO()  # De.Gelukkige.Huisvrouw.2010.DVDRip.XviD-FloW
     output.write(b"; sfv created by SFV Checker\n"
                  b";\n"
                  b""""gh-flow.subs.rar" 83a20923\n"""
                  b";\n"
                  b"; Total 1 File(s)	Combined CRC32 Checksum: 83a20923\n")
     (entries, comments, errors) = parse_sfv_file(output)
     # 		print([str(e) for e in entries])
     # 		print(comments)
     # 		print(errors)
     self.assertTrue(len(entries) == 1)
     self.assertTrue(len(comments) == 4)
     self.assertTrue(len(errors) == 0)
     self.assertEqual("gh-flow.subs.rar", entries[0].file_name)