def test_render_should_return_same_rendition_after_write(self): r1 = self.p1.render() self.p1.write() p2 = s2page.Page(self.site, self.p1slug, isslug=True) r2 = p2.render() self.assertEqual( r1, r2, "render gave different rendition after reading from file.")
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.")
def test_set_tags_read_tags_should_be_same_as_written_tags(self): #need auxiliary callable to test setter t = [u'elearning', u'arduino', u'tincan'] self.p1.tags = t self.p1.write() p2 = s2page.Page(self.site, self.p1slug, isslug=True) self.assertEqual(p2.tags, t, "read tags were not the same as written tags")
def test_set_date_read_date_should_be_same_as_written_date(self): #need auxiliary callable to test setter d = util.random_date() self.p1.creation_date = d self.p1.write() p2 = s2page.Page(self.site, self.p1slug, isslug=True) self.assertEqual(p2.creation_date, d.isoformat(), "read date was not the same as written date.")
def test_rename_with_existing_title_should_raise_ValueError(self): self.p1.write() newpagetitle = "Some new page here" #newpageslug = util.make_slug(newpagetitle) p2 = s2page.Page(self.site, newpagetitle, isslug=False) p2.write() #try to rename p1 and give it the same title as p2 self.assertRaises(ValueError, self.p1.rename, newpagetitle)
def test_set_published_and_write_read_again_should_read_correct_status( self): self.p1.set_published() self.p1.write() p2 = s2page.Page(self.site, self.p1slug, isslug=True) self.assertTrue( p2.published, "after setting status to published, write, and then read, status was not published." )
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
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.")
def test_inst_slug_pageExists_should_load_page(self): self.p1.write() p2 = s2page.Page(self.site, self.p1slug, isslug=True) self.assertEqual(p2.content, '\n' + self.p1.content + '\n', "Page content is not correct after loading page.")
def test_inst_noSlug_pageExists_should_raise_valueError(self): p1 = s2page.Page(self.site, "This is a new page") p1.write() self.assertRaises(ValueError, s2page.Page, self.site, "This is a new page")
def test_write_should_create_file(self): p1 = s2page.Page(self.site, "This is a new page") p1.write() self.assertTrue( os.path.isdir(p1.dirs['source_dir']) and \ os.path.isfile(p1.dirs['source_filename']), "No directory and/or file created after page write.")
def test_inst_noSlug_should_create_page(self): p = s2page.Page(self.site, "This is a new page") self.assertIsInstance( p, s2page.Page, "Page instantiation did not create a page object.")