Skip to content

Commit

Permalink
rename fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetretto committed Jun 26, 2024
1 parent 559e238 commit 79df076
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/jobflow_remote/jobs/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ def run_one_job(
if job_id:
query["uuid"] = job_id[0]
query["index"] = job_id[1]
print(query)
job_data = self.job_controller.checkout_job(query=query)
if not job_data:
if not db_id and not job_id:
Expand Down
2 changes: 1 addition & 1 deletion tests/db/cli/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest


def test_reset(job_controller, four_jobs):
def test_reset(job_controller, two_flows_four_jobs):
from jobflow_remote.testing.cli import run_check_cli

run_check_cli(
Expand Down
29 changes: 17 additions & 12 deletions tests/db/cli/test_flow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest


def test_flows_list(job_controller, four_jobs):
def test_flows_list(job_controller, two_flows_four_jobs):
from jobflow_remote.testing.cli import run_check_cli

columns = ["DB id", "Name", "State", "Flow id", "Num Jobs", "Last updated"]
Expand All @@ -17,23 +17,25 @@ def test_flows_list(job_controller, four_jobs):
run_check_cli(["flow", "list", "-m", "1"], required_out=outputs)

outputs = ["READY"]
run_check_cli(["flow", "list", "-fid", four_jobs[0].uuid], required_out=outputs)
run_check_cli(
["flow", "list", "-fid", two_flows_four_jobs[0].uuid], required_out=outputs
)


def test_delete(job_controller, four_jobs):
def test_delete(job_controller, two_flows_four_jobs):
from jobflow_remote.jobs.runner import Runner
from jobflow_remote.jobs.state import JobState
from jobflow_remote.testing.cli import run_check_cli

# run one of the jobs to check that the output is not deleted
runner = Runner()
job_1_uuid = four_jobs[0].jobs[0].uuid
job_1_uuid = two_flows_four_jobs[0].jobs[0].uuid
runner.run_one_job(job_id=(job_1_uuid, 1))
assert job_controller.get_job_doc(job_id=job_1_uuid).state == JobState.COMPLETED
assert job_controller.jobstore.get_output(job_1_uuid) == 6

run_check_cli(
["flow", "delete", "-fid", four_jobs[0].uuid],
["flow", "delete", "-fid", two_flows_four_jobs[0].uuid],
required_out="Deleted Flow",
cli_input="y",
)
Expand All @@ -42,30 +44,33 @@ def test_delete(job_controller, four_jobs):

# run the command without returning any match
run_check_cli(
["flow", "delete", "-fid", four_jobs[0].uuid],
["flow", "delete", "-fid", two_flows_four_jobs[0].uuid],
required_out="No flows matching criteria",
)

# don't confirm and verbose option
# only check the first characters of the uuid because it may be cut in the output
outputs = ["This operation will delete the following 1 Flow", four_jobs[1].uuid[:5]]
outputs = [
"This operation will delete the following 1 Flow",
two_flows_four_jobs[1].uuid[:5],
]
run_check_cli(
["flow", "delete", "-fid", four_jobs[1].uuid, "-v"],
["flow", "delete", "-fid", two_flows_four_jobs[1].uuid, "-v"],
required_out=outputs,
cli_input="n",
)
assert job_controller.count_flows() == 1

# run one job and delete with the outputs
runner = Runner()
job_2_uuid = four_jobs[1].jobs[0].uuid
job_2_uuid = two_flows_four_jobs[1].jobs[0].uuid
runner.run_one_job(job_id=(job_2_uuid, 1))
assert job_controller.get_job_doc(job_id=job_2_uuid).state == JobState.COMPLETED
assert job_controller.jobstore.get_output(job_2_uuid) == 6

outputs = [f"Deleted Flow(s) with id: {four_jobs[1].uuid}"]
outputs = [f"Deleted Flow(s) with id: {two_flows_four_jobs[1].uuid}"]
run_check_cli(
["flow", "delete", "-fid", four_jobs[1].uuid, "-o"],
["flow", "delete", "-fid", two_flows_four_jobs[1].uuid, "-o"],
required_out=outputs,
cli_input="y",
)
Expand All @@ -76,7 +81,7 @@ def test_delete(job_controller, four_jobs):
job_controller.jobstore.get_output(job_2_uuid)


def test_flow_info(job_controller, four_jobs):
def test_flow_info(job_controller, two_flows_four_jobs):
from jobflow_remote.testing.cli import run_check_cli

columns = ["DB id", "Name", "State", "Job id", "(Index)", "Worker"]
Expand Down
16 changes: 8 additions & 8 deletions tests/db/cli/test_job.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def test_jobs_list(job_controller, four_jobs):
def test_jobs_list(job_controller, two_flows_four_jobs):
from jobflow_remote.jobs.state import JobState
from jobflow_remote.testing.cli import run_check_cli

Expand Down Expand Up @@ -30,7 +30,7 @@ def test_jobs_list(job_controller, four_jobs):
)


def test_job_info(job_controller, four_jobs):
def test_job_info(job_controller, two_flows_four_jobs):
from jobflow_remote.testing.cli import run_check_cli

outputs = ["name = 'add1'", "state = 'READY'"]
Expand All @@ -40,7 +40,7 @@ def test_job_info(job_controller, four_jobs):

outputs += excluded_n
run_check_cli(
["job", "info", four_jobs[0].jobs[0].uuid, "-n"], required_out=outputs
["job", "info", two_flows_four_jobs[0].jobs[0].uuid, "-n"], required_out=outputs
)

outputs = ["state = 'READY'", "job = {"]
Expand All @@ -51,7 +51,7 @@ def test_job_info(job_controller, four_jobs):
)


def test_set_state(job_controller, four_jobs):
def test_set_state(job_controller, two_flows_four_jobs):
from jobflow_remote.jobs.state import JobState
from jobflow_remote.testing.cli import run_check_cli

Expand All @@ -66,7 +66,7 @@ def test_set_state(job_controller, four_jobs):
)


def test_rerun(job_controller, four_jobs):
def test_rerun(job_controller, two_flows_four_jobs):
from jobflow_remote.jobs.state import JobState
from jobflow_remote.testing.cli import run_check_cli

Expand All @@ -81,7 +81,7 @@ def test_rerun(job_controller, four_jobs):
run_check_cli(["job", "rerun", "-did", "1"], required_out="Error while rerunning")


def test_retry(job_controller, four_jobs):
def test_retry(job_controller, two_flows_four_jobs):
from jobflow_remote.jobs.state import JobState
from jobflow_remote.testing.cli import run_check_cli

Expand All @@ -96,7 +96,7 @@ def test_retry(job_controller, four_jobs):
run_check_cli(["job", "retry", "-did", "2"], required_out="Error while retrying")


def test_play_pause(job_controller, four_jobs):
def test_play_pause(job_controller, two_flows_four_jobs):
from jobflow_remote.jobs.state import JobState
from jobflow_remote.testing.cli import run_check_cli

Expand All @@ -115,7 +115,7 @@ def test_play_pause(job_controller, four_jobs):
run_check_cli(["job", "play", "-did", "1"], required_out="Error while playing")


def test_stop(job_controller, four_jobs):
def test_stop(job_controller, two_flows_four_jobs):
from jobflow_remote.jobs.state import JobState
from jobflow_remote.testing.cli import run_check_cli

Expand Down
2 changes: 1 addition & 1 deletion tests/db/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def one_job(random_project_name):


@pytest.fixture(scope="function")
def four_jobs(random_project_name):
def two_flows_four_jobs(random_project_name):
"""
Add two flows with two jobs each to the DB
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/db/jobs/test_jobcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def test_set_job_doc_properties(job_controller, one_job):
assert job_controller.get_job_doc(job_id=one_job[0].uuid).job.metadata == {"x": "y"}


def test_reset(job_controller, four_jobs):
def test_reset(job_controller, two_flows_four_jobs):
assert job_controller.count_jobs() == 4

assert not job_controller.reset(max_limit=1)
Expand Down

0 comments on commit 79df076

Please sign in to comment.