<commit_before>## This file is part of Indico.
## Copyright (C) 2002 - 2014 European Organization for Nuclear Research (CERN).
##
## Indico is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 3 of the
## License, or (at your option) any later version.
##
## Indico 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
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Indico; if not, see <http://www.gnu.org/licenses/>.

import pytest

from indico.modules.rb.models.rooms import Room


pytest_plugins = 'indico.modules.rb.testing.fixtures'


def test_is_auto_confirm(create_room, bool_flag):
    room = create_room(reservations_need_confirmation=bool_flag)
    assert room.is_auto_confirm != bool_flag
    assert Room.find_first(is_auto_confirm=bool_flag) is None
    assert Room.find_first(is_auto_confirm=not bool_flag) == room


@pytest.mark.parametrize(('building', 'floor', 'number', 'name', 'expected_name'), (
    (u'1', u'2', u'3', u'',       u'1-2-3'),
    (u'1', u'2', u'X', u'',       u'1-2-X'),
    (u'1', u'X', u'3', u'',       u'1-X-3'),
    (u'X', u'2', u'3', u'',       u'X-2-3'),
    (u'1', u'2', u'3', u'Test',   u'1-2-3 - Test'),
    (u'1', u'2', u'3', u'm\xf6p', u'1-2-3 - m\xf6p')
))
def test_full_name(create_room, building, floor, number, name, expected_name):
    room = create_room(building=building, floor=floor, number=number, name=name)
    assert room.full_name == expected_name


@pytest.mark.parametrize(('name', 'expected'), (<commit_msg>Add booking_url and details_url tests<commit_after>## This file is part of Indico.
## Copyright (C) 2002 - 2014 European Organization for Nuclear Research (CERN).
##
## Indico is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 3 of the
## License, or (at your option) any later version.
##
## Indico 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
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Indico; if not, see <http://www.gnu.org/licenses/>.

import pytest

from indico.modules.rb.models.rooms import Room


pytest_plugins = 'indico.modules.rb.testing.fixtures'


def test_is_auto_confirm(create_room, bool_flag):
    room = create_room(reservations_need_confirmation=bool_flag)
    assert room.is_auto_confirm != bool_flag
    assert Room.find_first(is_auto_confirm=bool_flag) is None
    assert Room.find_first(is_auto_confirm=not bool_flag) == room


def test_booking_url(dummy_room):
    assert Room().booking_url is None
    assert dummy_room.booking_url is not None


def test_details_url(dummy_room):
    assert Room().details_url is None
    assert dummy_room.details_url is not None


@pytest.mark.parametrize(('building', 'floor', 'number', 'name', 'expected_name'), (
    (u'1', u'2', u'3', u'',       u'1-2-3'),
    (u'1', u'2', u'X', u'',       u'1-2-X'),
    (u'1', u'X', u'3', u'',       u'1-X-3'),
    (u'X', u'2', u'3', u'',       u'X-2-3'),
    (u'1', u'2', u'3', u'Test',   u'1-2-3 - Test'),
    (u'1', u'2', u'3', u'm\xf6p', u'1-2-3 - m\xf6p')
))
def test_full_name(create_room, building, floor, number, name, expected_name):
    room = create_room(building=building, floor=floor, number=number, name=name)
    assert room.full_name == expected_name


@pytest.mark.parametrize(('name', 'expected'), (
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.021144920061887573, 'mean_word_length': 4.206711409395973, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '807394', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1308, 'n_words': 408}