def test_variables_are_added(self): vars = {} vars["title"] = "Test Title" vars["created"] = datetime.now() vars["updated"] = datetime.now() + timedelta(hours=1) content = "{%hyde\n" for key, value in vars.iteritems(): content += " %s: %s\n" % (key, value) content += "%}" out = File(self.site.content_folder.child("test_yaml.html")) self.site.monitor(self.queue) t = Thread(target=self.yaml_checker, kwargs={"path":out.path, "vars":vars}) t.start() out.write(content) t.join() assert self.exception_queue.empty() # Ensure default values are added for all pages # temp = File(self.site.content_folder.child("test.html")) temp.write('text') page = Page(temp, self.site.content_node) assert not page.title assert page.created == datetime.strptime("2000-01-01", "%Y-%m-%d") assert page.updated == page.created temp.delete() out.delete()
def test_variables_are_added(self): vars = {} vars["title"] = "Test Title" vars["created"] = datetime.now() vars["updated"] = datetime.now() + timedelta(hours=1) content = "{%hyde\n" for key, value in vars.iteritems(): content += " %s: %s\n" % (key, value) content += "%}" out = File(self.site.content_folder.child("test_yaml.html")) self.site.monitor(self.queue) t = Thread(target=self.yaml_checker, kwargs={"path":out.path, "vars":vars}) t.start() out.write(content) t.join() assert self.exception_queue.empty() # Ensure default values are added for all pages # temp = File(self.site.content_folder.child("test_var.html")) temp.write('text') page = Page(temp, self.site.content_node) assert not page.title assert page.created == datetime.strptime("2000-01-01", "%Y-%m-%d") assert page.updated == page.created temp.delete() out.delete()
def test_delete(self): f = File(self.site.content_folder.child("test.ddd")) f.write("test") self.site.refresh() self.clean_queue() self.site.monitor(self.queue) t = Thread(target=self.change_checker, kwargs={"change":"Deleted", "path":f.path}) t.start() f.delete() t.join() assert self.exception_queue.empty()
def test_add(self, direct=False): self.site.monitor(self.queue) path = self.site.layout_folder.child("test.ggg") t = Thread(target=self.change_checker, kwargs={"change":"Added", "path":path}) t.start() f = File(path) f.write("test") t.join() if not direct: f.delete() assert self.exception_queue.empty()
def test_underscored_pages_are_not_rendered(self): self.generator = Generator(TEST_SITE.path) self.generator.build_siteinfo() source = File(TEST_ROOT.child("test_src.html")) target = File(self.site.content_folder.child("_test.html")) self.site.refresh() self.site.monitor(self.queue) t = Thread(target=self.checker, kwargs={"asserter":self.assert_layout_not_rendered}) t.start() source.copy_to(target) t.join() target.delete() assert self.exception_queue.empty()
def dopost(self, site): path = self.get_argument("path", None) type = self.get_argument('type', None) repo = self.settings['sites'][site]['repo'] dvcs = DVCS.load_dvcs(self.siteinfo.folder.path, repo) f = None if type == "file": f = File(self.siteinfo.folder.child(path)) else: f = Folder(self.siteinfo.folder.child(path)) f.delete() dvcs.save_draft() self.init_site(site, force=True)
def test_dates_are_converted_to_datetime(self): vars = {} vars["created"] = datetime.now().date() vars["updated"] = (datetime.now() + timedelta(hours=1)).date() content = "{%hyde\n" for key, value in vars.iteritems(): content += " %s: %s\n" % (key, value) content += "%}" out = File(self.site.content_folder.child("test_yaml.html")) out.write(content) page = Page(out, self.site.content_node) assert not page.title assert page.created == datetime.combine(vars["created"], time()) assert page.updated == datetime.combine(vars["updated"], time()) out.delete()
def test_textile(self): try: import textile except ImportError: textile = False print "Textile not found, skipping unit tests" if textile: self.generator = Generator(TEST_SITE.path) self.generator.build_siteinfo() source = File(TEST_ROOT.child("src_test_textile.html")) self.site.refresh() self.site.monitor(self.queue) t = Thread(target=self.checker, kwargs={"asserter":self.assert_valid_textile}) t.start() target = File(self.site.content_folder.child("test.html")) source.copy_to(target) t.join() target.delete() assert self.exception_queue.empty()
def test_textile(self): try: import textile except ImportError: textile = False print "Textile not found, skipping unit tests" if textile: self.generator = Generator(TEST_SITE.path) self.generator.build_siteinfo() source = File(TEST_ROOT.child("src_test_textile.html")) self.site.refresh() self.site.monitor(self.queue) t = Thread(target=self.checker, kwargs={"asserter":self.assert_valid_textile}) t.start() target = File(self.site.content_folder.child("test_textile.html")) source.copy_to(target) t.join() target.delete() assert self.exception_queue.empty()