예제 #1
0
 def test_rename_page_should_create_correct_data_in_sourcedir(self):
     title = "This is a new page" 
     slug = util.make_slug(title)
     p = s2page.Page(self.s2,title)
     p.write()
     new_title = "This HELLO dude will be the new name"
     self.s2.rename_page(slug,new_title)
     slist = self.s2.get_page_names()
     self.assertTrue(util.make_slug(new_title) in slist,"The new name does not exist in the source.")
예제 #2
0
 def test_rename_page_should_create_correct_data_in_sourcedir(self):
     title = "This is a new page"
     slug = util.make_slug(title)
     p = s2page.Page(self.s2, title)
     p.write()
     new_title = "This HELLO dude will be the new name"
     self.s2.rename_page(slug, new_title)
     slist = self.s2.get_page_names()
     self.assertTrue(
         util.make_slug(new_title) in slist,
         "The new name does not exist in the source.")
예제 #3
0
 def test_rename_old_sourcedir_shoud_not_exist_in_source(self):
     self.p1.write()
     oldpageslug = self.p1slug
     newpagetitle = "Some new page here"
     newpageslug = util.make_slug(newpagetitle)
     self.p1.rename(newpagetitle)
     self.assertFalse(self.site.page_exists_on_disk(oldpageslug),"The old page slug still exists in source after rename.")
예제 #4
0
 def test_peod_on_nonexisting_page_should_return_false(self):
     title = "This is a new page"
     slug = util.make_slug(title)
     #p1 = s2page.Page(self.s2,title)
     # we DO NOT write it, so it doesn't exist!
     self.assertFalse(self.s2.page_exists_on_disk(slug),
                      "page.exists returned True on a non-existing page.")
예제 #5
0
 def test_peod_on_existing_page_should_return_true(self):
     title = "This is a new page"
     slug = util.make_slug(title)
     p1 = s2page.Page(self.s2, title)
     p1.write()
     self.assertTrue(
         self.s2.page_exists_on_disk(slug),
         "page_exists_on_disk returned False on existing page.")
예제 #6
0
 def test_rename_new_sourcedir_shoud_exist_in_source(self):
     self.p1.write()
     newpagetitle = "Some new page here"
     newpageslug = util.make_slug(newpagetitle)
     self.p1.rename(newpagetitle)
     self.assertTrue(
         self.site.page_exists_on_disk(newpageslug),
         "The new page slug does not exist in source after rename.")
예제 #7
0
 def test_rename_content_should_be_the_same(self):
     self.p1.write()
     oldcontent = self.p1.content
     oldpageslug = self.p1slug
     newpagetitle = "Some new page here"
     newpageslug = util.make_slug(newpagetitle)
     self.p1.rename(newpagetitle)
     newcontent = self.p1.content
     self.assertEqual(newcontent,oldcontent,"The content of the page has changed after rename.")
예제 #8
0
 def test_rename_old_sourcedir_shoud_not_exist_in_source(self):
     self.p1.write()
     oldpageslug = self.p1slug
     newpagetitle = "Some new page here"
     newpageslug = util.make_slug(newpagetitle)
     self.p1.rename(newpagetitle)
     self.assertFalse(
         self.site.page_exists_on_disk(oldpageslug),
         "The old page slug still exists in source after rename.")
예제 #9
0
 def test_rename_content_should_be_the_same(self):
     self.p1.write()
     oldcontent = self.p1.content
     oldpageslug = self.p1slug
     newpagetitle = "Some new page here"
     newpageslug = util.make_slug(newpagetitle)
     self.p1.rename(newpagetitle)
     newcontent = self.p1.content
     self.assertEqual(newcontent, oldcontent,
                      "The content of the page has changed after rename.")
예제 #10
0
 def setUp(self):
     self.temp_dir = tempfile.mkdtemp()
     self.site = s2site.Site(self.temp_dir)
     self.site.init_structure()
     #first create a page
     self.p1title = "This is a new page" 
     self.p1slug = util.make_slug(self.p1title)
     self.p1 = s2page.Page(self.site,self.p1title)
     content = util.random_text()
     self.p1.content = content
예제 #11
0
 def setUp(self):
     self.temp_dir = tempfile.mkdtemp()
     self.site = s2site.Site(self.temp_dir)
     self.site.init_structure()
     #first create a page
     self.p1title = "This is a new page"
     self.p1slug = util.make_slug(self.p1title)
     self.p1 = s2page.Page(self.site, self.p1title)
     content = util.random_text()
     self.p1.content = content
예제 #12
0
 def test_do_add_should_create_page_in_source(self):
     # init site
     site = s2site.Site(self.temp_dir)
     site.init_structure()
     # add page
     title = 'This is the new page title'
     args = self.parser.parse_args(['add',title,'-d',self.temp_dir])
     argdict = vars(args)
     s2.dispatch(argdict)  #this triggers call to do_add
     # verify that the page is there
     self.assertTrue(site.page_exists_on_disk(util.make_slug(title)),"page does not exist after add_page.")
예제 #13
0
 def test_do_add_should_create_page_in_source(self):
     # init site
     site = s2site.Site(self.temp_dir)
     site.init_structure()
     # add page
     title = 'This is the new page title'
     args = self.parser.parse_args(['add', title, '-d', self.temp_dir])
     argdict = vars(args)
     s2.dispatch(argdict)  #this triggers call to do_add
     # verify that the page is there
     self.assertTrue(site.page_exists_on_disk(util.make_slug(title)),
                     "page does not exist after add_page.")
예제 #14
0
 def test_do_rename_should_create_new_pagedir_in_source(self):
     # init site
     site = s2site.Site(self.temp_dir)
     site.init_structure()
     # add random page
     p = site.random_page()
     newtitle = "This will be the new title of the page."
     args = self.parser.parse_args(['rename', p.slug, newtitle, '-d', self.temp_dir])
     argdict = vars(args)
     s2.dispatch(argdict)  #this triggers call to do_rename
     # verify that the page is there
     self.assertTrue(site.page_exists_on_disk(util.make_slug(newtitle)),"new page directory does not exist after rename.")
     # and that the old page is not there.
     #Maybe it's a little unorthodox to do another assert in the same test... but it's for brevity
     self.assertFalse(site.page_exists_on_disk(p.slug),"old page still exists after rename.")
예제 #15
0
 def setUp(self):
    # create fake tempdir with the structure
     self.temp_dir = tempfile.mkdtemp()
     self.site = s2site.Site(self.temp_dir)
     self.site.init_structure()
     self.ntg = random.randint(8,100)
     self.gpi= []
     for i in range(0,self.ntg):
         title = util.random_title()
         self.gpi.append( { 'slug': util.make_slug(title),
                       'title': title,
                       'date': util.random_date()}
                   )   
     self.epp = random.randint(5,self.ntg)
     self.correctnumpag = math.ceil(float(self.ntg)/self.epp)
예제 #16
0
 def setUp(self):
     # create fake tempdir with the structure
     self.temp_dir = tempfile.mkdtemp()
     self.s2 = s2site.Site(self.temp_dir)
     self.s2.init_structure()
     # create a bunch of fake pages
     pgs = []
     for i in range(0, 11):
         pg = util.make_slug(util.random_title())
         pgs.append(pg)
         pgfp = os.path.join(self.s2.dirs['source'], pg)
         os.mkdir(pgfp)
         fname = os.path.join(pgfp, pg) + '.s2md'
         fout = open(fname, 'w')
         fout.close()
     self.pages = pgs
예제 #17
0
 def setUp(self):
     # create fake tempdir with the structure
     self.temp_dir = tempfile.mkdtemp()
     self.site = s2site.Site(self.temp_dir)
     self.site.init_structure()
     self.ntg = random.randint(8, 100)
     self.gpi = []
     for i in range(0, self.ntg):
         title = util.random_title()
         self.gpi.append({
             'slug': util.make_slug(title),
             'title': title,
             'date': util.random_date()
         })
     self.epp = random.randint(5, self.ntg)
     self.correctnumpag = math.ceil(float(self.ntg) / self.epp)
예제 #18
0
 def setUp(self):
     # create fake tempdir with the structure
     self.temp_dir = tempfile.mkdtemp()
     self.s2 = s2site.Site(self.temp_dir)
     self.s2.init_structure()
     # create a bunch of fake pages
     pgs = []
     for i in range(0,11):
         pg = util.make_slug(util.random_title())
         pgs.append(pg)
         pgfp = os.path.join(self.s2.dirs['source'],pg)
         os.mkdir(pgfp)
         fname = os.path.join(pgfp,pg) + '.s2md'
         fout = open(fname,'w')
         fout.close()
     self.pages = pgs
예제 #19
0
 def test_do_rename_should_create_new_pagedir_in_source(self):
     # init site
     site = s2site.Site(self.temp_dir)
     site.init_structure()
     # add random page
     p = site.random_page()
     newtitle = "This will be the new title of the page."
     args = self.parser.parse_args(
         ['rename', p.slug, newtitle, '-d', self.temp_dir])
     argdict = vars(args)
     s2.dispatch(argdict)  #this triggers call to do_rename
     # verify that the page is there
     self.assertTrue(site.page_exists_on_disk(util.make_slug(newtitle)),
                     "new page directory does not exist after rename.")
     # and that the old page is not there.
     #Maybe it's a little unorthodox to do another assert in the same test... but it's for brevity
     self.assertFalse(site.page_exists_on_disk(p.slug),
                      "old page still exists after rename.")
예제 #20
0
 def test_peod_on_nonexisting_page_should_return_false(self):
     title = "This is a new page" 
     slug = util.make_slug(title)
     #p1 = s2page.Page(self.s2,title)
     # we DO NOT write it, so it doesn't exist!
     self.assertFalse(self.s2.page_exists_on_disk(slug),"page.exists returned True on a non-existing page.")
예제 #21
0
 def test_rename_new_sourcedir_shoud_exist_in_source(self):
     self.p1.write()
     newpagetitle = "Some new page here"
     newpageslug = util.make_slug(newpagetitle)
     self.p1.rename(newpagetitle)
     self.assertTrue(self.site.page_exists_on_disk(newpageslug),"The new page slug does not exist in source after rename.")
예제 #22
0
def random_path(depth=3):
    pcs = []
    for i in range(0, depth + 1):
        pcs.append(util.make_slug(util.random_title()))
    rp = '/'.join(pcs)
    return rp
예제 #23
0
 def test_peod_on_existing_page_should_return_true(self):
     title = "This is a new page" 
     slug = util.make_slug(title)
     p1 = s2page.Page(self.s2,title)
     p1.write()
     self.assertTrue(self.s2.page_exists_on_disk(slug),"page_exists_on_disk returned False on existing page.")
예제 #24
0
def random_path(depth=3):
    pcs = []
    for i in range(0,depth+1):
        pcs.append(util.make_slug(util.random_title()))
    rp = '/'.join(pcs)
    return rp