<commit_before>import pytest
import os
import datetime
from context import cwd
from pylogrotate.main import parse_config, Rotator


def test_parse(config):
    assert config[0]['paths'] == ['/var/log/nginx/*.log']
    assert config[0]['period'] == 'daily'
    assert config[0]['user'] == 'www-data'
    assert config[0]['group'] == 'root'
    assert config[0]['prerotate'] == ['if [ -d /etc/logrotate.d/httpd-prerotate ]; then\n  run-parts /etc/logrotate.d/httpd-prerotate;\nfi']


@pytest.fixture
def config():
    return parse_config(os.path.join(cwd, 'config.yml'))


@pytest.fixture
def rotator(config):
    return Rotator(config[0])


class TestRotater(object):
    def test_get_rotated_time(self, rotator):
        path = '/var/log/nginx/access.log-20160910101030'
        assert rotator.get_rotated_time(path) == datetime.datetime(2016, 9, 10, 10, 10, 30)

    def test_get_rotated_time(self, rotator):
        with pytest.raises(Exception):
            rotator.get_rotated_time('/var/log/nginx/access.log-20160910-1010301')

        with pytest.raises(Exception):
            rotator.get_rotated_time('/var/log/nginx/access.log-201609101')

        with pytest.raises(Exception):
            rotator.get_rotated_time('/var/log/nginx/access.log201609101')

    def test_remove_old_files(self, rotator):
        pass
<commit_msg>Update tests<commit_after>import pytest
import os
import datetime
from context import cwd
from pylogrotate.main import parse_config, Rotator


def test_parse(config):
    assert config[0]['paths'] == ['/var/log/nginx/*.log']
    assert config[0]['period'] == 'daily'
    assert config[0]['user'] == 'www-data'
    assert config[0]['group'] == 'root'
    assert config[0]['prerotate'] == ['if [ -d /etc/logrotate.d/httpd-prerotate ]; then\n  run-parts /etc/logrotate.d/httpd-prerotate;\nfi']


@pytest.fixture
def config():
    return parse_config(os.path.join(cwd, 'config.yml'))


@pytest.fixture
def rotator(config):
    return Rotator(config[0])


class TestRotator(object):

    def test_get_rotated_time(self, rotator):
        path = '/var/log/nginx/access.log-20160910101030'
        assert rotator.get_rotated_time(path) == datetime.datetime(2016, 9, 10, 10, 10, 30)

    def test_get_rotated_time2(self, rotator):
        with pytest.raises(Exception):
            rotator.get_rotated_time('/var/log/nginx/access.log-20160910-1010301')

        with pytest.raises(Exception):
            rotator.get_rotated_time('/var/log/nginx/access.log-201609101')

        with pytest.raises(Exception):
            rotator.get_rotated_time('/var/log/nginx/access.log201609101')

    def test_remove_old_files(self, rotator):
        pass

    def test_skip_empty_files(self, rotator):
        pass

{'fraction_non_alphanumeric': 0.14280483339436104, 'fraction_numerical': 0.048700109849871845, 'mean_word_length': 3.6621160409556315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1312009', 'n_tokens_mistral': 1050, 'n_tokens_neox': 949, 'n_words': 163}