<commit_before># Copyright (c) 2014, <NAME>

import os
import tempfile
import unittest

from handroll.configuration import Configuration
from handroll.site import Site


class TestSite(unittest.TestCase):

    def _make_valid_site(self):
        site = tempfile.mkdtemp()
        open(os.path.join(site, 'template.html'), 'w').close()
        return Site(site)

    def test_generates_with_user_specified_outdir(self):
        site = self._make_valid_site()
        marker = 'marker.txt'
        open(os.path.join(site.path, marker), 'w').close()
        config = Configuration()
        config.outdir = tempfile.mkdtemp()

        site.generate(config)

        out_marker = os.path.join(config.outdir, marker)
        self.assertTrue(os.path.exists(out_marker))

    def test_cleans_output(self):
        site = self._make_valid_site()
        os.mkdir(site.output_root)

        site._clean_output()

        self.assertFalse(os.path.exists(site.output_root))

    def test_skips_file_with_skip_extension(self):
        site = self._make_valid_site()
        skip = 'to_my_lou.swp'
        open(os.path.join(site.path, skip), 'w').close()
        config = Configuration()

        site.generate(config)

        out_skip = os.path.join(site.output_root, skip)
        self.assertFalse(os.path.exists(out_skip))

    def test_skips_file_in_skip_list(self):
        site = self._make_valid_site()
        skip = Site.CONFIG
        open(os.path.join(site.path, skip), 'w').close()
        config = Configuration()

        site.generate(config)

        out_skip = os.path.join(site.output_root, skip)
        self.assertFalse(os.path.exists(out_skip))<commit_msg>More Site coverage.<commit_after># Copyright (c) 2014, <NAME>

import os
import tempfile
import unittest

from handroll.configuration import Configuration
from handroll.exceptions import AbortError
from handroll.site import Site


class TestSite(unittest.TestCase):

    def _make_valid_site(self):
        site = tempfile.mkdtemp()
        open(os.path.join(site, 'template.html'), 'w').close()
        return Site(site)

    def test_generates_with_user_specified_outdir(self):
        site = self._make_valid_site()
        marker = 'marker.txt'
        open(os.path.join(site.path, marker), 'w').close()
        config = Configuration()
        config.outdir = tempfile.mkdtemp()

        site.generate(config)

        out_marker = os.path.join(config.outdir, marker)
        self.assertTrue(os.path.exists(out_marker))

    def test_cleans_output(self):
        site = self._make_valid_site()
        os.mkdir(site.output_root)

        site._clean_output()

        self.assertFalse(os.path.exists(site.output_root))

    def test_skips_file_with_skip_extension(self):
        site = self._make_valid_site()
        skip = 'to_my_lou.swp'
        open(os.path.join(site.path, skip), 'w').close()
        config = Configuration()

        site.generate(config)

        out_skip = os.path.join(site.output_root, skip)
        self.assertFalse(os.path.exists(out_skip))

    def test_skips_file_in_skip_list(self):
        site = self._make_valid_site()
        skip = Site.CONFIG
        open(os.path.join(site.path, skip), 'w').close()
        config = Configuration()

        site.generate(config)

        out_skip = os.path.join(site.output_root, skip)
        self.assertFalse(os.path.exists(out_skip))

    def test_skips_templates_directory(self):
        site = self._make_valid_site()
        templates = os.path.join(site.path, 'templates')
        os.mkdir(templates)
        config = Configuration()

        site.generate(config)

        out_templates = os.path.join(site.output_root, 'templates')
        self.assertFalse(os.path.exists(out_templates))

    def test_finds_valid_site_root_from_templates(self):
        original = os.getcwd()
        valid_site = tempfile.mkdtemp()
        open(os.path.join(valid_site, 'template.html'), 'w').close()
        os.chdir(valid_site)

        site = Site()

        self.assertEqual(valid_site, site.path)
        os.chdir(original)

    def test_finds_valid_site_root_from_conf(self):
        original = os.getcwd()
        valid_site = tempfile.mkdtemp()
        open(os.path.join(valid_site, Site.CONFIG), 'w').close()
        os.chdir(valid_site)

        site = Site()

        self.assertEqual(valid_site, site.path)
        os.chdir(original)
{'fraction_non_alphanumeric': 0.11935189411227749, 'fraction_numerical': 0.0018256503879507074, 'mean_word_length': 2.8481123792800704, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2615742', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1377, 'n_words': 224}