7
7
8
8
from jupyter_scheduler .models import (
9
9
CreateJobDefinition ,
10
+ EventType ,
10
11
ListJobDefinitionsQuery ,
11
12
SortDirection ,
12
13
SortField ,
13
14
UpdateJobDefinition ,
14
15
)
15
16
from jupyter_scheduler .orm import JobDefinition
16
17
18
+ test_job_definition_parameters = {
19
+ "input_uri" : "helloworld.ipynb" ,
20
+ "runtime_environment_name" : "default" ,
21
+ "name" : "hello world" ,
22
+ "output_formats" : ["ipynb" ]
23
+ }
17
24
18
25
def test_create_job_definition (jp_scheduler ):
19
26
with patch ("jupyter_scheduler.scheduler.fsspec" ) as mock_fsspec :
20
27
with patch ("jupyter_scheduler.scheduler.Scheduler.file_exists" ) as mock_file_exists :
21
28
mock_file_exists .return_value = True
22
- job_definition_id = jp_scheduler .create_job_definition (
23
- CreateJobDefinition (
24
- input_uri = "helloworld.ipynb" ,
25
- runtime_environment_name = "default" ,
26
- name = "hello world" ,
27
- output_formats = ["ipynb" ],
28
- )
29
- )
29
+ job_definition_id = jp_scheduler .create_job_definition (CreateJobDefinition (** test_job_definition_parameters ))
30
30
31
31
with jp_scheduler .db_session () as session :
32
32
definitions = session .query (JobDefinition ).all ()
@@ -40,6 +40,26 @@ def test_create_job_definition(jp_scheduler):
40
40
assert [] == definition .on_events
41
41
42
42
43
+ event_type_parameters = {
44
+ "name" : 'type1' ,
45
+ "parameters" : {'param1' : 'value1' }
46
+ }
47
+
48
+ def test_create_job_definition_with_on_events (jp_scheduler ):
49
+ with patch ("jupyter_scheduler.scheduler.fsspec" ) as mock_fsspec :
50
+ with patch ("jupyter_scheduler.scheduler.Scheduler.file_exists" ) as mock_file_exists :
51
+ mock_file_exists .return_value = True
52
+ event_type = EventType (** event_type_parameters )
53
+ params_with_on_events = {** test_job_definition_parameters , "on_events" : [event_type ]}
54
+ jp_scheduler .create_job_definition (CreateJobDefinition (** params_with_on_events ))
55
+
56
+ with jp_scheduler .db_session () as session :
57
+ definitions = session .query (JobDefinition ).all ()
58
+ definition = definitions [0 ]
59
+ assert 1 == len (definition .on_events )
60
+ assert [{'name' : 'type1' , 'parameters' : {'param1' : 'value1' }}] == definition .on_events
61
+
62
+
43
63
job_definition_1 = {
44
64
"job_definition_id" : "f4f8c8a9-f539-429a-b69e-b567f578646e" ,
45
65
"name" : "hello world 1" ,
0 commit comments