Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision fc7747df7177f2f610c55c9709a81e7b0b618806 authored by Jochen Kupperschmidt on 03 January 2026, 00:21:02 UTC, committed by Jochen Kupperschmidt on 03 January 2026, 00:21:02 UTC
Display only language icon on CozyLAN locale selector dropdown button
1 parent 2e587a4
  • Files
  • Changes
  • 86abe66
  • /
  • tests
  • /
  • unit
  • /
  • services
  • /
  • seating
  • /
  • test_are_preconditions_met.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:fc7747df7177f2f610c55c9709a81e7b0b618806
directory badge
swh:1:dir:9afbd2bde31b1d8fcabb5b91f7f053ecbbf2028b
content badge
swh:1:cnt:7fbde0d771653df78c3983cccc284ecca9f3faf1

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
test_are_preconditions_met.py
"""
:Copyright: 2014-2025 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""

from datetime import datetime

import pytest

from byceps.services.party.models import PartyID
from byceps.services.seating.models import SeatReservationPrecondition
from byceps.services.seating.seat_reservation_domain_service import (
    are_preconditions_met,
    create_precondition,
)


@pytest.mark.parametrize(
    ('now', 'ticket_quantity', 'expected'),
    [
        (datetime(2025, 6, 16, 18, 0, 0), 11, False),  # too early
        (datetime(2025, 6, 17, 18, 0, 0), 11, True),
        (datetime(2025, 6, 17, 18, 0, 0), 10, True),
        (datetime(2025, 6, 17, 18, 0, 0), 10, True),
        (datetime(2025, 6, 17, 17, 59, 59), 10, False),  # too early
        (datetime(2025, 6, 17, 18, 0, 0), 9, False),  # too few tickets
        (datetime(2025, 6, 18, 18, 0, 0), 6, True),
        (datetime(2025, 6, 18, 18, 0, 0), 5, True),
        (datetime(2025, 6, 18, 18, 0, 0), 5, True),
        (datetime(2025, 6, 18, 17, 59, 59), 5, False),  # too early
        (datetime(2025, 6, 18, 18, 0, 0), 4, False),  # too few tickets
        (datetime(2025, 6, 19, 18, 0, 0), 2, True),
        (datetime(2025, 6, 19, 18, 0, 0), 1, True),
        (datetime(2025, 6, 19, 18, 0, 0), 1, True),
        (datetime(2025, 6, 19, 17, 59, 59), 1, False),  # too early
        (datetime(2025, 6, 19, 18, 0, 0), 0, False),  # too few tickets
        (datetime(2025, 6, 20, 18, 0, 0), 1, True),
        (datetime(2025, 6, 20, 18, 0, 0), 0, False),  # too few tickets
    ],
)
def test_are_preconditions_met(preconditions, now, ticket_quantity, expected):
    actual = are_preconditions_met(preconditions, now, ticket_quantity)
    assert actual == expected


@pytest.fixture(scope='module')
def preconditions() -> set[SeatReservationPrecondition]:
    party_id = PartyID('party-2025')

    return {
        create_precondition(party_id, datetime(2025, 6, 17, 18, 0, 0), 10),
        create_precondition(party_id, datetime(2025, 6, 18, 18, 0, 0), 5),
        create_precondition(party_id, datetime(2025, 6, 19, 18, 0, 0), 1),
    }


def test_reservation_without_preconditions_is_denied():
    preconditions = set()
    now = datetime(2025, 6, 20, 18, 0, 0)
    ticket_quantity = 99

    assert not are_preconditions_met(preconditions, now, ticket_quantity)
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API