Skip to content

Commit

Permalink
use fixture for root dir
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-i committed May 6, 2024
1 parent 7edf55b commit e55be92
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
13 changes: 10 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@


@pytest.fixture
def jp_scheduler_staging(jp_data_dir):
def jp_scheduler_root_dir(tmp_path):
root_dir = tmp_path / "workspace_root"
root_dir.mkdir()
return root_dir


@pytest.fixture
def jp_scheduler_staging_dir(jp_data_dir):
staging_area = jp_data_dir / "scheduler_staging_area"
staging_area.mkdir()
return staging_area


@pytest.fixture
def jp_scheduler_db_url(jp_scheduler_staging):
db_file_path = jp_scheduler_staging / "scheduler.sqlite"
def jp_scheduler_db_url(jp_scheduler_staging_dir):
db_file_path = jp_scheduler_staging_dir / "scheduler.sqlite"
return f"sqlite:///{db_file_path}"


Expand Down
18 changes: 13 additions & 5 deletions jupyter_scheduler/tests/test_execution_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@


@pytest.fixture
def create_job(jp_scheduler_db):
def staging_dir_with_side_effects(jp_scheduler_staging_dir):
return ("side_effects.ipynb", "output_side_effect.txt")


@pytest.fixture
def side_effects_job_record(jp_scheduler_db, staging_dir_with_side_effects):
notebook_name = staging_dir_with_side_effects[0]
job = Job(
runtime_environment_name="abc",
input_filename=NOTEBOOK_NAME,
input_filename=notebook_name,
)
jp_scheduler_db.add(job)
jp_scheduler_db.commit()
return job.job_id


def test_add_side_effects_files(jp_scheduler_db, create_job, jp_scheduler_db_url):
job_id = create_job
def test_add_side_effects_files(
jp_scheduler_db, side_effects_job_record, jp_scheduler_db_url, jp_scheduler_root_dir
):
job_id = side_effects_job_record
manager = DefaultExecutionManager(
job_id=job_id,
root_dir=str(NOTEBOOK_DIR),
root_dir=jp_scheduler_root_dir,
db_url=jp_scheduler_db_url,
staging_paths={"input": str(NOTEBOOK_PATH)},
)
Expand Down

0 comments on commit e55be92

Please sign in to comment.