Skip to content

Commit

Permalink
Refactor test_simple_generator.py to simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
Pabloo22 committed Feb 15, 2024
1 parent f68d4f3 commit 36ae9d7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions tests/test_simple_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,18 @@ def test_generate():
instance = generator.generate(num_jobs=5, num_machines=5)
assert len(instance.jobs) == 5
for job in instance.jobs:
assert len(job) == 5 # Ensure each job has 5 operations
assert len(job) == 5
machine_ids = [op.machine_id for op in job]
machines_are_unique = len(set(machine_ids)) == 5
assert machines_are_unique
for op in job:
assert (
5 <= op.duration <= 10
) # Ensure operation duration is within bounds
assert 5 <= op.duration <= 10


@pytest.mark.parametrize("limit", [1, 5, 10])
def test_iteration_limit(limit):
generator = SimpleGenerator(
max_duration=10, iteration_limit=limit, seed=42
)
instances = list(generator) # Utilize the generator's iterable nature
assert (
len(instances) == limit
) # Ensure the number of instances matches the iteration limit
instances = list(generator)
assert len(instances) == limit

0 comments on commit 36ae9d7

Please sign in to comment.