Beispiel #1
0
def test_no_progress_while_at_max_capacity():
    """While the factory is at max capacity, no work on creating the next resource
    shall be done."""
    factory = Factory(0, 0, creates=Resource.RED, interval=1, max_capacity=1)
    factory.resources = [Resource.RED]
    factory.update(0.5)
    assert factory.time_to_next_production > 0.99
Beispiel #2
0
def test_start_production_when_free_capacity():
    """Once there is free capacity, production shall resume."""
    factory = Factory(0, 0, creates=Resource.RED, interval=1, max_capacity=1)
    factory.resources = [Resource.RED]
    factory.update(1.1)
    factory.pop()
    factory.update(1.1)
    factory.resources = [Resource.RED]
Beispiel #3
0
def test_create_one_resource():
    """One resource shall be created after the specified interval has passed."""
    factory = Factory(0, 0, creates=Resource.RED, interval=1, max_capacity=1)
    factory.update(1.1)
    assert factory.resources == [Resource.RED]
Beispiel #4
0
def test_a_factory_producing_none_shall_not_produce_anything():
    """If it produces None, nothing shall be produced."""
    factory = Factory(0, 0, creates=None, interval=1, max_capacity=1)
    factory.update(1.1)
    assert factory.resources == []
Beispiel #5
0
def test_max_capacity():
    """The number of resources cannot exceed max capacity."""
    factory = Factory(0, 0, creates=Resource.RED, interval=1, max_capacity=1)
    factory.update(1.1)
    factory.update(1.1)
    assert factory.resources == [Resource.RED]
Beispiel #6
0
def test_create_two_resources():
    """Two resources shall be crated after the specified interval has passed twice."""
    factory = Factory(0, 0, creates=Resource.RED, interval=1, max_capacity=2)
    factory.update(1.1)
    factory.update(1.1)
    assert factory.resources == [Resource.RED, Resource.RED]