Пример #1
0
 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()
Пример #2
0
 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()
Пример #3
0
    def dopost(self, site):
        path = self.get_argument("path", None)
        original_path = self.get_argument("original_path", None)
        type = self.get_argument('type', None)
        repo = self.settings['sites'][site]['repo']
        dvcs = DVCS.load_dvcs(self.siteinfo.folder.path, repo)
        if type == "file":
            f = File(self.siteinfo.folder.child(original_path))
            newf = File(self.siteinfo.folder.child(path))
            if not f.exists:
                newf.write("")
                dvcs.add_file(newf)
            else:
                f.move_to(newf)
                dvcs.add_file(newf, message="Renamed " + path)

        else:
            f = Folder(self.siteinfo.folder.child(original_path))
            newf = Folder(self.siteinfo.folder.child(path))
            if not f.exists:
                newf.make()
            else:
                f.move_to(newf)
                dvcs.add_file(newf, message="Renamed " + path)
        self.init_site(site, force=True)
Пример #4
0
    def dopost(self, site):
        path = self.get_argument("path", None)
        original_path = self.get_argument("original_path", None)
        type = self.get_argument('type', None)
        repo = self.settings['sites'][site]['repo']
        dvcs = DVCS.load_dvcs(self.siteinfo.folder.path, repo)
        if type == "file":
            f = File(self.siteinfo.folder.child(original_path))
            newf = File(self.siteinfo.folder.child(path))
            if not f.exists:
                newf.write("")
                dvcs.add_file(newf)
            else:
                f.move_to(newf)
                dvcs.add_file(newf, message="Renamed " + path)

        else:
            f = Folder(self.siteinfo.folder.child(original_path))
            newf = Folder(self.siteinfo.folder.child(path))
            if not f.exists:
                newf.make()
            else:
                f.move_to(newf)
                dvcs.add_file(newf, message="Renamed " + path)
        self.init_site(site, force=True)
Пример #5
0
    def dopost(self, site):
        path = self.get_argument("path", None)
        if not path: return
        content = self.get_argument("content", None)
        f = File(self.siteinfo.folder.child(path))
        f.write(content)

        repo = self.settings['sites'][site]['repo']
        dvcs = DVCS.load_dvcs(self.siteinfo.folder.path, repo)
        dvcs.save_draft()
Пример #6
0
    def dopost(self, site):
        path = self.get_argument("path", None)
        if not path: return
        content = self.get_argument("content", None)
        f = File(self.siteinfo.folder.child(path))
        f.write(content)

        repo = self.settings['sites'][site]['repo']
        dvcs = DVCS.load_dvcs(self.siteinfo.folder.path, repo)
        dvcs.save_draft()
Пример #7
0
 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()
Пример #8
0
 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() 
Пример #9
0
 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()
Пример #10
0
 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()
Пример #11
0
 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()
Пример #12
0
 def test_delete_dir(self):
     d = self.site.content_folder.child_folder("test_test")
     f = File(d.child("test.nnn"))
     d.make()
     f.write("test")
     self.site.refresh() 
     self.clean_queue()
     self.site.monitor(self.queue)
     t = Thread(target=self.node_remove_checker, 
                 kwargs={"change":"NodeRemoved", "path":d.path})
     t.start()      
     d.delete()
     t.join()
     d.delete()
     assert self.exception_queue.empty()
Пример #13
0
 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()
Пример #14
0
 def test_delete_dir(self):
     d = self.site.content_folder.child_folder("test_test")
     f = File(d.child("test.nnn"))
     d.make()
     f.write("test")
     self.site.refresh()
     self.clean_queue()
     self.site.monitor(self.queue)
     t = Thread(target=self.node_remove_checker,
                 kwargs={"change":"NodeRemoved", "path":d.path})
     t.start()
     d.delete()
     t.join()
     d.delete()
     assert self.exception_queue.empty()
Пример #15
0
    def test_filters(self):
        site = SiteInfo(settings, TEST_SITE.path)
        for name in [".banjo", ".hidden", "junk.abc~"]:
            f = File(site.content_folder.child(name))
            self.files.append(f)
            f.write("junk")
        
        git = site.content_folder.child_folder(".git")
        git_child = git.child_folder("child")
        git_child_pack = File(git_child.child("pack"))
        git.make()
        git_child.make()
        git_index = File(git.child("index"))
        git_index.write("junk")
        git_child_pack.write("junk")
            
        original_exclude = settings.FILTER['exclude']
        original_include = settings.FILTER['include']
        settings.FILTER = {}
        site = SiteInfo(settings, TEST_SITE.path)
        site.refresh()
        
        for f in self.files:
            assert site.find_resource(f)
            
        assert site.find_node(git)
        assert site.find_resource(git_index)
        assert site.find_node(git_child)
        assert site.find_resource(git_child_pack)

        settings.FILTER = { 
            'include': (),
            'exclude': (".*","*~")
        }
        
        site = SiteInfo(settings, TEST_SITE.path)        
        site.refresh()
        
        for f in self.files:
            assert not site.find_resource(f)
            
        assert not site.find_node(git)
        assert not site.find_resource(git_index)  
        assert not site.find_node(git_child)
        assert not site.find_resource(git_child_pack)  
            
        settings.FILTER = { 
            'include': (".banjo",),
            'exclude': (".*","*~")
        }

        site = SiteInfo(settings, TEST_SITE.path)        
        site.refresh()

        for f in self.files:
            if f.name == ".banjo":
                assert site.find_resource(f)
            else:
                assert not site.find_resource(f)    
                
        assert not site.find_node(git)
        assert not site.find_resource(git_index)        
            
        settings.FILTER['exclude']  = original_exclude
        settings.FILTER['include']  = original_include
        
        self.files.append(git)
Пример #16
0
    def test_filters(self):
        site = SiteInfo(settings, TEST_SITE.path)
        for name in [".banjo", ".hidden", "junk.abc~"]:
            f = File(site.content_folder.child(name))
            self.files.append(f)
            f.write("junk")

        git = site.content_folder.child_folder(".git")
        git_child = git.child_folder("child")
        git_child_pack = File(git_child.child("pack"))
        git.make()
        git_child.make()
        git_index = File(git.child("index"))
        git_index.write("junk")
        git_child_pack.write("junk")

        original_exclude = settings.FILTER['exclude']
        original_include = settings.FILTER['include']
        settings.FILTER = {}
        site = SiteInfo(settings, TEST_SITE.path)
        site.refresh()

        for f in self.files:
            assert site.find_resource(f)

        assert site.find_node(git)
        assert site.find_resource(git_index)
        assert site.find_node(git_child)
        assert site.find_resource(git_child_pack)

        settings.FILTER = {
            'include': (),
            'exclude': (".*","*~")
        }

        site = SiteInfo(settings, TEST_SITE.path)
        site.refresh()

        for f in self.files:
            assert not site.find_resource(f)

        assert not site.find_node(git)
        assert not site.find_resource(git_index)
        assert not site.find_node(git_child)
        assert not site.find_resource(git_child_pack)

        settings.FILTER = {
            'include': (".banjo",),
            'exclude': (".*","*~")
        }

        site = SiteInfo(settings, TEST_SITE.path)
        site.refresh()

        for f in self.files:
            if f.name == ".banjo":
                assert site.find_resource(f)
            else:
                assert not site.find_resource(f)

        assert not site.find_node(git)
        assert not site.find_resource(git_index)

        settings.FILTER['exclude']  = original_exclude
        settings.FILTER['include']  = original_include

        self.files.append(git)