def test_clientProvidedDuplicateContent(self): # Check the new behaviour specified by LibrarianTransactions # spec: allow duplicate content with distinct IDs. content = 'some content' # Store a file with id 6661 newfile1 = LibraryFileUpload(self.storage, 'filename', 0) newfile1.contentID = 6661 newfile1.append(content) fileid1, aliasid1 = newfile1.store() # Store second file identical to the first, with id 6662 newfile2 = LibraryFileUpload(self.storage, 'filename', 0) newfile2.contentID = 6662 newfile2.append(content) fileid2, aliasid2 = newfile2.store() # Create rows in the database for these files. LibraryFileContent( filesize=0, sha1='foo', md5='xx', sha256='xx', id=6661) LibraryFileContent( filesize=0, sha1='foo', md5='xx', sha256='xx', id=6662) flush_database_updates()
def test_clientProvidedDuplicateContent(self): # Check the new behaviour specified by LibrarianTransactions # spec: allow duplicate content with distinct IDs. content = 'some content' # Store a file with id 6661 newfile1 = LibraryFileUpload(self.storage, 'filename', 0) newfile1.contentID = 6661 newfile1.append(content) fileid1, aliasid1 = newfile1.store() # Store second file identical to the first, with id 6662 newfile2 = LibraryFileUpload(self.storage, 'filename', 0) newfile2.contentID = 6662 newfile2.append(content) fileid2, aliasid2 = newfile2.store() # Create rows in the database for these files. LibraryFileContent(filesize=0, sha1='foo', md5='xx', sha256='xx', id=6661) LibraryFileContent(filesize=0, sha1='foo', md5='xx', sha256='xx', id=6662) flush_database_updates()
def test_clientProvidedDuplicateIDs(self): # This test checks the new behaviour specified by LibrarianTransactions # spec: don't create IDs in DB, but do check they don't exist. # Create a new file newfile = LibraryFileUpload(self.storage, 'filename', 0) # Set a content ID on the file (same as would happen with a # client-generated ID) and store it newfile.contentID = 666 newfile.store() newfile = LibraryFileUpload(self.storage, 'filename', 0) newfile.contentID = 666 self.assertRaises(DuplicateFileIDError, newfile.store)