<commit_before># This file is part of LiSE, a framework for life simulation games.
# Copyright (c) <NAME>, <EMAIL>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
import pytest


@pytest.fixture(scope='function')
def chara(engy):
    yield engy.new_character('chara')


def test_many_things_in_place(chara):
    place = chara.new_place(0)
    things = [place.new_thing(i) for i in range(1, 10)]
    for thing in things:
        assert thing in place.contents()
    for that in place.content:
        assert place.content[that].location == place
    things.sort(key=lambda th: th.name)
    contents = sorted(place.contents(), key=lambda th: th.name)
    assert things == contents


def test_contents_over_time(chara):
    place = chara.new_place(0)
    correct_contents = set()
    for i in range(10):
        chara.engine.next_turn()
        with chara.engine.advancing():
            place.new_thing(chara.engine.turn)
            del chara.thing[chara.engine.turn]
            assert set(place.content.keys()) == correct_contents
            place.new_thing(chara.engine.turn)
            correct_contents.add(chara.engine.turn)
        assert set(place.content.keys()) == correct_contents
    del chara.thing[9]
    correct_contents.remove(9)
    assert set(place.content.keys()) == correct_contents
    del chara.thing[8]
    correct_contents.remove(8)
    assert set(place.content.keys()) == correct_contents
    chara.engine.turn = 5
    del chara.thing[5]  # starts new branch
    assert set(place.content.keys()) == {1, 2, 3, 4}


def test_contents_in_plan(chara):
    place = chara.new_place(0)<commit_msg>Correct test_contents_over_time<commit_after># This file is part of LiSE, a framework for life simulation games.
# Copyright (c) <NAME>, <EMAIL>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
import pytest
from allegedb.window import HistoryError


@pytest.fixture(scope='function')
def chara(engy):
    yield engy.new_character('chara')


def test_many_things_in_place(chara):
    place = chara.new_place(0)
    things = [place.new_thing(i) for i in range(1, 10)]
    for thing in things:
        assert thing in place.contents()
    for that in place.content:
        assert place.content[that].location == place
    things.sort(key=lambda th: th.name)
    contents = sorted(place.contents(), key=lambda th: th.name)
    assert things == contents


def test_contents_over_time(chara):
    place = chara.new_place(0)
    correct_contents = set()
    for i in range(10):
        chara.engine.next_turn()
        with chara.engine.advancing():
            place.new_thing(chara.engine.turn)
            del chara.thing[chara.engine.turn]
            assert set(place.content.keys()) == correct_contents
            place.new_thing(chara.engine.turn)
            correct_contents.add(chara.engine.turn)
        assert set(place.content.keys()) == correct_contents
    del chara.thing[9]
    correct_contents.remove(9)
    assert set(place.content.keys()) == correct_contents
    del chara.thing[8]
    correct_contents.remove(8)
    assert set(place.content.keys()) == correct_contents
    chara.engine.turn = 5
    with pytest.raises(HistoryError):
        del chara.thing[5]
    chara.engine.branch = 'b'
    del chara.thing[5]
    assert set(place.content.keys()) == {1, 2, 3, 4}


def test_contents_in_plan(chara):
    place = chara.new_place(0)
{'fraction_non_alphanumeric': 0.10037093606807768, 'fraction_numerical': 0.00850970979707615, 'mean_word_length': 3.4634858812074003, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '7464271', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1367, 'n_words': 439}