def move(path, date=None): ''' Moves a page given its path. ''' page = Page(title=None, path=path) if os.path.exists(page.path): raise Exception("Page '%s' already exists" % (page.path, )) shutil.move(path, page.path) if not master.exists_doc(page.docname): master.append_doc(page.docname) return page
def create(title, template=None): ''' Creates a new page given its title. ''' page = Page(title, path=None) if os.path.exists(page.path): raise Exception("Page '%s' already exists at '%s" % (title, page.path)) page.write(template=template) if not master.exists_doc(page.docname): master.append_doc(page.docname) return page
def move(path, date=None): ''' Moves a page given its path. ''' page = Page(title=None, path=path) if os.path.exists(page.path): raise Exception("Page '%s' already exists at '%s" % (title, page.path)) shutil.move(path, page.path) if not master.exists_doc(page.docname): master.append_doc(page.docname) return page
def create(title): ''' Creates a new page given its title. ''' page = Page(title, path=None) if os.path.exists(page.path): raise Exception("Page '%s' already exists at '%s" % (title, page.path)) page.write() if not master.exists_doc(page.docname): master.append_doc(page.docname) return page
def test_remove(self): # append 4 docs new_docs = ["a", "b", "c", "d"] for doc in new_docs: master.append_doc(doc) # remove 3 of them while checking master each time for doc_to_remove in ["c", "b", "d"]: master.remove_doc(doc_to_remove) new_docs.remove(doc_to_remove) self.assertEquals( TestMaster.MASTER_HEAD + [" %s\n" % doc for doc in new_docs] + TestMaster.MASTER_TAIL, master.read_master())
def test_append(self): new_docs = ["somewhere/somedoc", "anotherdoc"] master.append_doc(new_docs[0]) # first doc should be appendend in the correct place self.assertEquals( TestMaster.MASTER_HEAD + [" %s\n" % new_docs[0]] + TestMaster.MASTER_TAIL, master.read_master()) master.append_doc(new_docs[1]) # second doc should be appended in the correct place self.assertEquals( TestMaster.MASTER_HEAD + [" %s\n" % new_docs[0], " %s\n" % new_docs[1]] + TestMaster.MASTER_TAIL, master.read_master())