<commit_before>from merfi.collector import RepoCollector
from os.path import join, dirname


class TestRepoCollector(object):

    def setup(self):
        self.paths = RepoCollector(path='/', _eager=False)

    def test_simple_tree(self, repotree):
        paths = RepoCollector(path=repotree)
        # The root of the repotree fixture is itself a repository.
        expected = [ repotree ]
        assert set(paths) == set(expected)

    def test_path_is_absolute(self):
        assert self.paths._abspath('/') == '/'

    def test_path_is_not_absolute(self):
        assert self.paths._abspath('directory').startswith('/')

    def test_debian_release_files(self, repotree):
        paths = RepoCollector.debian_release_files(repotree)
        # The root of the repotree fixture is itself a repository.
        expected = [
            join(repotree, 'dists', 'trusty', 'Release'),
            join(repotree, 'dists', 'precise', 'Release'),
        ]
        assert set(paths) == set(expected)

    def test_debian_nested_release_files(self, repotree):
        path = dirname(repotree)
        paths = RepoCollector(path)
        release_files = paths.debian_release_files
        expected = [
            join(repotree, 'dists', 'trusty', 'Release'),
            join(repotree, 'dists', 'precise', 'Release'),
        ]
        assert set(release_files) == set(expected)
<commit_msg>update tests to use the new repocollector behavior<commit_after>from merfi.collector import RepoCollector
from os.path import join, dirname


class TestRepoCollector(object):

    def setup(self):
        self.paths = RepoCollector(path='/', _eager=False)

    def test_simple_tree(self, repotree):
        paths = RepoCollector(path=repotree)
        # The root of the repotree fixture is itself a repository.
        expected = [ repotree ]
        assert set(paths) == set(expected)

    def test_path_is_absolute(self):
        assert self.paths._abspath('/') == '/'

    def test_path_is_not_absolute(self):
        assert self.paths._abspath('directory').startswith('/')

    def test_debian_release_files(self, repotree):
        paths = RepoCollector(repotree)
        release_files = paths.debian_release_files
        # The root of the repotree fixture is itself a repository.
        expected = [
            join(repotree, 'dists', 'trusty', 'Release'),
            join(repotree, 'dists', 'precise', 'Release'),
        ]
        assert set(release_files) == set(expected)

    def test_debian_nested_release_files(self, nested_repotree):
        # go one level up
        path = dirname(nested_repotree)
        paths = RepoCollector(path)
        release_files = paths.debian_release_files
        expected = [
            join(nested_repotree, 'dists', 'trusty', 'Release'),
            join(nested_repotree, 'dists', 'precise', 'Release'),
        ]
        assert set(release_files) == set(expected)

{'fraction_non_alphanumeric': 0.11007911936704506, 'fraction_numerical': 0.0, 'mean_word_length': 2.9297297297297296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2210906', 'n_tokens_mistral': 900, 'n_tokens_neox': 876, 'n_words': 197}