<commit_before>import datetime
import time
from time import sleep
from uuid import uuid4

from eventsourcing.domain.model.timebucketedlog import Timebucketedlog, bucket_duration, bucket_starts, \
    make_timebucket_id, start_new_timebucketedlog
from eventsourcing.infrastructure.repositories.timebucketedlog_repo import TimebucketedlogRepo
from eventsourcing.infrastructure.timebucketedlog_reader import TimebucketedlogReader
from eventsourcing.tests.base import notquick
from eventsourcing.tests.sequenced_item_tests.base import WithPersistencePolicies
from eventsourcing.tests.sequenced_item_tests.test_cassandra_active_record_strategy import \
    WithCassandraActiveRecordStrategies
from eventsourcing.tests.sequenced_item_tests.test_sqlalchemy_active_record_strategy import \
    WithSQLAlchemyActiveRecordStrategies


class TimebucketedlogTestCase(WithPersistencePolicies):
    def setUp(self):
        super(TimebucketedlogTestCase, self).setUp()
        self.log_repo = TimebucketedlogRepo(self.log_event_store)

    def test_entity_lifecycle(self):
        log_name = uuid4()
        log = self.log_repo.get_or_create(log_name=log_name, bucket_size='year')
        self.assertIsInstance(log, Timebucketedlog)
        self.assertEqual(log.name, log_name)
        self.assertEqual(log.bucket_size, 'year')

        # Append some messages to the log.
        message1 = 'This is message 1'
        message2 = 'This is message 2'
        message3 = 'This is message 3'
        message4 = 'This is message 4'
        message5 = 'This is message 5'
        message6 = 'This is message 6'
        event1 = log.append_message(message1)
        event2 = log.append_message(message2)
        event3 = log.append_message(message3)
        halfway = time.time()
        event4 = log.append_message(message4)
        event5 = log.append_message(message5)<commit_msg>Fixed test.<commit_after>import datetime
import time
from time import sleep
from uuid import uuid4

from eventsourcing.domain.model.timebucketedlog import Timebucketedlog, bucket_duration, bucket_starts, \
    make_timebucket_id, start_new_timebucketedlog
from eventsourcing.infrastructure.repositories.timebucketedlog_repo import TimebucketedlogRepo
from eventsourcing.infrastructure.timebucketedlog_reader import TimebucketedlogReader
from eventsourcing.tests.base import notquick
from eventsourcing.tests.sequenced_item_tests.base import WithPersistencePolicies
from eventsourcing.tests.sequenced_item_tests.test_cassandra_active_record_strategy import \
    WithCassandraActiveRecordStrategies
from eventsourcing.tests.sequenced_item_tests.test_sqlalchemy_active_record_strategy import \
    WithSQLAlchemyActiveRecordStrategies


class TimebucketedlogTestCase(WithPersistencePolicies):
    def setUp(self):
        super(TimebucketedlogTestCase, self).setUp()
        self.log_repo = TimebucketedlogRepo(self.entity_event_store)

    def test_entity_lifecycle(self):
        log_name = uuid4()
        log = self.log_repo.get_or_create(log_name=log_name, bucket_size='year')
        log = self.log_repo[log_name]
        self.assertIsInstance(log, Timebucketedlog)
        self.assertEqual(log.name, log_name)
        self.assertEqual(log.bucket_size, 'year')

        # Append some messages to the log.
        message1 = 'This is message 1'
        message2 = 'This is message 2'
        message3 = 'This is message 3'
        message4 = 'This is message 4'
        message5 = 'This is message 5'
        message6 = 'This is message 6'
        event1 = log.append_message(message1)
        event2 = log.append_message(message2)
        event3 = log.append_message(message3)
        halfway = time.time()
        event4 = log.append_message(message4)
        event5 = log.append_message(message5)
{'fraction_non_alphanumeric': 0.06613545816733067, 'fraction_numerical': 0.012749003984063745, 'mean_word_length': 4.19448275862069, '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': '4032537', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1096, 'n_words': 228}