Example #1
0
File: tests.py Project: durden/stag
    def generateAndCheck(self):
        """Generate site and verify all files exist"""

        self.assertTrue(os.path.isdir(self.src_dir),
                                                'Missing %s' % (self.src_dir))

        stag.generate(self.src_dir, self.dest_dir, self.templates)

        self.assertTrue(os.path.isdir(self.dest_dir),
                                                'Missing %s' % (self.dest_dir))

        for root, dirs, files in os.walk(self.src_dir):
            for file_name in files:
                md_ext = ''.join([os.extsep, 'md'])
                markdown_ext = ''.join([os.extsep, 'markdown'])

                if not file_name.endswith(md_ext) and not \
                        file_name.endswith(markdown_ext):
                    continue

                gen_file = re.sub(self.src_dir, self.dest_dir,
                                                os.path.join(root, file_name))

                gen_file = os.path.normpath(gen_file.replace('.md', '.html'))
                gen_file = os.path.normpath(gen_file.replace('.markdown',
                                                                    '.html'))

                self.assertTrue(os.path.isfile(gen_file),
                                                    'Missing %s' % gen_file)

        for root, dirs, files in os.walk(self.dest_dir):
            for gen_file in files:
                self.assertTrue(gen_file.endswith('.html'),
                                                    'Non-html file in output')
Example #2
0
File: tests.py Project: durden/stag
    def test_missing_src_dir(self):
        """Verify missing src directory is handled"""

        self.src_dir = 'this/is/not/a/real/dir'
        self.dest_dir = 'dest'
        self.templates = {'header': 'layout/header.html',
                          'footer': 'layout/footer.html'}
        self.assertTrue(stag.generate(self.src_dir, self.dest_dir,
                                                    self.templates) == 0)