def test_file_openable(self): """ Tests that CreateNewTab.fileUploaded can open a file """ testfile = CreateNewTab.fileUploaded("loaded_file.odt", "append") # check loaded_file.ods, .odp too # check that html file loaded_file.html is there if not os.path.exists('loaded_file.html'): print('HTML file not created') contenttype, encoding = mimetypes.guess_type('loaded_file.html') if contenttype == None or encoding is not None: contenttype = '?/?' maintype, subtype = contenttype.split('/', 1) if maintype == 'text' and subtype == 'html': return else: raise WrongFileError("That's not an HTML file!" ) cssfile = open('file1.css', 'r') contenttype, encoding = mimetypes.guess_type(cssfile) if contenttype == None or encoding is not None: contenttype = '?/?' maintype, subtype = contenttype.split('/', 1) if maintype == 'text' and subtype == 'css': return else: raise WrongFileError("That's not a css file.")
def test_new_file(self): """ Tests CreateNewTab.newFile, for returning an html file. """ testfile = CreateNewTab.newFile("testfile") if not os.path.exists(testfile): print("File doesn't exist") contenttype, encoding = mimetypes.guess_type(testfile) if contenttype == None or encoding is not None: contenttype = '?/?' maintype, subtype = contenttype.split('/', 1) if maintype == 'text' and subtype == 'html': return else: raise WrongFileError("That's not an HTML file!" )