15
15
)
16
16
from jupyter_scheduler .orm import JobDefinition
17
17
18
- test_job_definition_parameters = {
18
+ test_job_def_params = {
19
19
"input_uri" : "helloworld.ipynb" ,
20
20
"runtime_environment_name" : "default" ,
21
21
"name" : "hello world" ,
22
22
"output_formats" : ["ipynb" ],
23
23
}
24
24
25
+ < << << << HEAD
25
26
26
27
def test_create_job_definition (jp_scheduler ):
27
28
with patch ("jupyter_scheduler.scheduler.fsspec" ) as mock_fsspec :
@@ -30,6 +31,18 @@ def test_create_job_definition(jp_scheduler):
30
31
job_definition_id = jp_scheduler .create_job_definition (
31
32
CreateJobDefinition (** test_job_definition_parameters )
32
33
)
34
+ == == == =
35
+ def create_job_definition (jp_scheduler , job_def_params ):
36
+ with patch ("jupyter_scheduler.scheduler.fsspec" ) as mock_fsspec :
37
+ with patch ("jupyter_scheduler.scheduler.Scheduler.file_exists" ) as mock_file_exists :
38
+ mock_file_exists .return_value = True
39
+ job_definition_id = jp_scheduler .create_job_definition (CreateJobDefinition (** job_def_params ))
40
+
41
+ return job_definition_id
42
+
43
+ def test_create_job_definition (jp_scheduler ):
44
+ job_definition_id = create_job_definition (jp_scheduler , test_job_def_params )
45
+ > >> >> >> fb76d81 (add and use create_job_definition helper function )
33
46
34
47
with jp_scheduler .db_session () as session :
35
48
definitions = session .query (JobDefinition ).all ()
@@ -47,12 +60,8 @@ def test_create_job_definition(jp_scheduler):
47
60
48
61
49
62
def test_create_job_definition_with_on_events (jp_scheduler ):
50
- with patch ("jupyter_scheduler.scheduler.fsspec" ) as mock_fsspec :
51
- with patch ("jupyter_scheduler.scheduler.Scheduler.file_exists" ) as mock_file_exists :
52
- mock_file_exists .return_value = True
53
- event_type = EventType (** event_type_parameters )
54
- params_with_on_events = {** test_job_definition_parameters , "on_events" : [event_type ]}
55
- jp_scheduler .create_job_definition (CreateJobDefinition (** params_with_on_events ))
63
+ params_with_on_events = {** test_job_def_params , "on_events" : [EventType (** event_type_parameters )]}
64
+ create_job_definition (jp_scheduler , params_with_on_events )
56
65
57
66
with jp_scheduler .db_session () as session :
58
67
definitions = session .query (JobDefinition ).all ()
0 commit comments