Skip to content

Commit

Permalink
Make work queues test a bit more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
bunchesofdonald committed Dec 9, 2022
1 parent 734eb88 commit 0bddced
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/orion/models/test_work_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ async def test_delete_work_queue_returns_false_if_does_not_exist(self, session):


class TestGetRunsInWorkQueue:
running_flow_count = 4
running_flow_states = [
schemas.states.StateType.PENDING,
schemas.states.StateType.CANCELLING,
schemas.states.StateType.RUNNING,
schemas.states.StateType.RUNNING,
]

@pytest.fixture
async def work_queue_2(self, session):
Expand Down Expand Up @@ -272,15 +277,8 @@ async def scheduled_flow_runs(self, session, deployment, work_queue, work_queue_

@pytest.fixture
async def running_flow_runs(self, session, deployment, work_queue, work_queue_2):
for i in range(self.running_flow_count):
for state_type in self.running_flow_states:
for wq in [work_queue, work_queue_2]:
if i == 0:
state_type = "PENDING"
elif i == 1:
state_type = "CANCELLING"
else:
state_type = "RUNNING"

await models.flow_runs.create_flow_run(
session=session,
flow_run=schemas.core.FlowRun(
Expand Down Expand Up @@ -378,7 +376,7 @@ async def test_get_runs_in_queue_concurrency_limit(
)

assert len(runs_wq1) == max(
0, min(3, concurrency_limit - self.running_flow_count)
0, min(3, concurrency_limit - len(self.running_flow_states))
)

@pytest.mark.parametrize("limit", [10, 1])
Expand All @@ -404,4 +402,6 @@ async def test_get_runs_in_queue_concurrency_limit_and_limit(
session=session, work_queue_id=work_queue.id, limit=limit
)

assert len(runs_wq1) == min(limit, concurrency_limit - self.running_flow_count)
assert len(runs_wq1) == min(
limit, concurrency_limit - len(self.running_flow_states)
)

0 comments on commit 0bddced

Please sign in to comment.